When run following command it gives me permission denied
message for all the files.
find /data/code/ -name "*.jar" -exec {} ls \;
find: `/data/code/project/shared/build/thirdparty/log4j-1.2.8/commons-logging-1.0.4.jar': Permission denied
But if I do
ls /data/code/project/shared/build/thirdparty/log4j-1.2.8/commons-logging-1.0.4.jar
It prints gives the proper output without any permission denied
message.
/data/code/project/shared/build/thirdparty/log4j-1.2.8/commons-logging-1.0.4.jar
What am I doing wrong?
p.s. : I need to list and remove all the jar files in /data/code
Best Answer
While doing:
you are trying the execute the file found (e.g.
/data/code/project/shared/build/thirdparty/log4j-1.2.8/commons-logging-1.0.4.jar
) withls
as an argument to it, leading to the permission denied error.Just switch the order:
GNU
find
has-ls
option too, so in GNUfind
, you can just do: