Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-13-2004, 10:35 AM
|
#1
|
LQ Newbie
Registered: Jul 2004
Posts: 13
Rep:
|
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.
|
|
|
08-13-2004, 11:03 AM
|
#2
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
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!)
|
|
|
08-13-2004, 11:21 AM
|
#3
|
Member
Registered: Aug 2003
Location: Little Rock, Arkansas
Distribution: RH, Fedora, Suse, AIX
Posts: 736
Rep:
|
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
|
|
|
10-10-2008, 12:26 PM
|
#4
|
Member
Registered: Jan 2005
Location: Norfolk, VA
Posts: 32
Rep:
|
Quote:
Originally Posted by Donboy
Sounds like you're going to flunk this class!
|
ROFL, thanks for making me laugh my ass off!
|
|
|
10-10-2008, 08:42 PM
|
#5
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,407
|
|
|
|
All times are GMT -5. The time now is 03:22 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|