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.

if $1 ; then
    find $1 -name "*.sh" > temp.txt

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

sudo chmod 770 `cat temp.txt`

Here is a full output of the error:

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

Recommended Answers

All 3 Replies


if test -n "$1"

and, as you can see, use more quotes.

I also had posted this on ubuntu forums. The solution made me feel very much a like a noob and can be found here: Ubuntu forum page

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.