Using Bash, Find script files in a directory or subdirectories within...
Hi, I doing an exercise which is looked like this:
"You are required to write a script using Bash, which can find out all the script programs under a directory and its subdirectories and then change its mode to be executable. Your script needs to satisfy the following requirements:
(a) test if the number of arguments is bigger than 1. Print out a usage message if the number of argument is 1.
(b) it can be run by the super user: root only.
(c) Before it changes file's mode, it should ask the user to confirm.
(d) It needs to print out the path of all the scripts whose permission have been modified. "
For part (a), i can use variable $1 to test if there is an argument.
For part (b), i can check using $UID=0, since root is always 0
For part (c), i just print a message and if the input is y for yes, then i continue, else i just use 'exit 0' to exit fomr this script
please correct me if i was wrong
Now the problem is i had no idea how to search for all the sript programs within the directory and its subdirectories. i also got no idea for part (d).
I would really appreaciate for any good advices given.
Re: Using Bash, Find script files in a directory or subdirectories within...
And in general, see "man bash" (long!)
Sounds like you're going to flunk this class! LOL!
Seriously, tho... it's a bad idea to come to the forums asking people to do your homework for you. It's better to try doing everything you can to figure it out yourself and then come here with your specific questions about how to get over the hump or whatever has got you stuck.
From the looks of your post, it seems like you need some very basic help getting started. I recommend Googling for some basic help. There are lots and lots of webpages already written that will give you the answers to most of your questions.
Here is a link that will get you started...
I suggest you bookmark these:
As mentioned, read up on 'find' and 'echo'
|All times are GMT -5. The time now is 03:12 PM.|