jera jera - 5 months ago 51
Linux Question

Linux find -exec permission denied

I wrote a shell script iterating through files and ordering their contents and saving the new order back to the file.


for i in "$@"; do
sort $i -k2 -o $i

The files to be sorted are chosen with the
command like so:

find . -regex '<myregex>' -exec ./ {} +

I wrote the script and tried it out one machine as a specific user and then copied it over to another machine using root privileges. So now the files has
chown root:root
as have all the files I wand to search through.

So now the files to be sorted are located in the same folder as the and when I try to execute the find with -exec i get

find: './': Permission denied

I tried moving the script to a subfolder and executing the command with
-exec ./folder/
or moving it to a higher level folder and executing it with
-exec ../
. I always get different variations of Permission denied errors.


Check if the filesystem was mounted with noexec flag.

But you can still run your script via bash:

bash /path/to/