bash script error: is a directory
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.
The worst part is this runs perfectly fine (without if statement obviously) going line by line in the shell but the sub shell that is reading the bash script is apparently having a hard time with what to do with directory that I am trying to pass into the find command (it apparently thinks I am trying to execute it)
Here is my code:
Code:
#!/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
(Just so you know. I am cross forum posting. I posted this same thing on daniweb. I dont know why people have a problem with cross posting on multiple forums that are different but I am looking for help from coders and from other linux users so I posted both places)
Antec 300 Illusion__________MSI 770-G45 AM3
AMD X6 3.0Ghz____________4gig ddr3 1600 GSKILL
1tb Seagate hd____________ATI 5850 xfx(OC soon)
_____________750w diablotek psu_______________
Bookmarks