My code is rather basic so excuse my lack of shell scripting experience. I keep getting errors for line 3. I have tried changing "$1" to echo $1 cat $1 and even turning the whole line into a variable which i read in another forum and then calling that variable seperately (the variable being inside of backquotes. It's giving me headaches seems like it should be simple. The goal is to make all .sh files rwx and to allow the user to pass an argument directory into the script so that it will change them in a specific directory rather than globally.

#!/bin/bash
if $1 ; then
    find $1 -name "*.sh" > temp.txt

else
    find /home -name "*.sh" > temp.txt
fi

sudo chmod 770 `cat temp.txt`

Here is a full output of the error:

jordan@fire:~$ ./test.sh ~/documents ./test.sh: line 6: /home/jordan/documents: is a directory find:/home/accounts': Permission denied

thank you Watael. your solution also worked and was intuitive for future scripting. Thanks again!

This question has already been answered. Start a new discussion instead.