LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Using Bash, Find script files in a directory or subdirectories within... (http://www.linuxquestions.org/questions/programming-9/using-bash-find-script-files-in-a-directory-or-subdirectories-within-217137/)

ray5_83 08-13-2004 09:35 AM

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.

Hko 08-13-2004 10:03 AM

Re: Using Bash, Find script files in a directory or subdirectories within...
 
Quote:

Originally posted by ray5_83
Now the problem is i had no idea how to search for all the sript programs within the directory and its subdirectories.
See "man find", or better yet "info find".
Quote:

i also got no idea for part (d).
See "man echo" or "info echo".

And in general, see "man bash" (long!)

Donboy 08-13-2004 10:21 AM

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...

http://www.google.com/search?hl=en&l...ll+script+bash

seanr 10-10-2008 11:26 AM

Quote:

Originally Posted by Donboy (Post 1107005)
Sounds like you're going to flunk this class!

ROFL, thanks for making me laugh my ass off!

chrism01 10-10-2008 07:42 PM

I suggest you bookmark these:

http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

As mentioned, read up on 'find' and 'echo'


All times are GMT -5. The time now is 03:47 PM.