I’m working on a script to find files with same permissions and then apply some optional commands from command line to them. After many hours I came up with this code
the command line would be like this:
codename 644 ls -l
and the script is the below code:
#!/bin/sh
permission=$1
shift
find . -maxdepth 1 -perm $permission exec $* {} \;
I believe that exec task is redirecting the result to the command line after shifting the first command which is the 644 here.
If i am wrong please correct me.
my problem is when I use the find line in the command line it works perfectly but after using it in the script it gives me an error
./codename 664 ls -l
find: paths must precede expression: exec
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path…] [expression]
You forgot the
$for permission and-forexec, so