Reputation: 322
I wrote a shell script iterating through files and ordering their contents and saving the new order back to the file.
#!/bin/sh
for i in "$@"; do
sort $i -k2 -o $i
done
The files to be sorted are chosen with the find
command like so:
find . -regex '<myregex>' -exec ./mysort.sh {} +
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 mysort.sh and when I try to execute the find with -exec i get
find: './mysort.sh': Permission denied
I tried moving the script to a subfolder and executing the command with -exec ./folder/mysort.sh
or moving it to a higher level folder and executing it with -exec ../mysort.sh
. I always get different variations of Permission denied errors.
Upvotes: 1
Views: 1961
Reputation: 3141
Check if the filesystem was mounted with noexec
flag.
But you can still run your script via bash
:
bash /path/to/mysort.sh
Upvotes: 2