LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-31-2004, 03:35 AM   #1
chii-chan
Member
 
Registered: Sep 2003
Location: chikyuu (E103N6)
Distribution: Redhat 8.0 (2.4.25-custom), Fedora Core 1 (2.4.30-custom)
Posts: 357

Rep: Reputation: 30
Script accept unlimited number of options.


Hi!

When you want the script to accept option you would do this something $1 right?

For example for a 'called remove':

#!/bin/bash

rm -i $1

Then execute it to remove files:

remove file file2

The script would remove the file given in the first option only right, so I add

#!/bin/bash

rm -i $1 $2

so that the script can remove the second file, but the process would be endless.

How do I have the script to accept unlimited number of options? Thanks.
 
Old 05-31-2004, 04:21 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
The variable "$@" will contain all of the parameters passed to a bash script.
 
Old 05-31-2004, 06:40 AM   #3
chii-chan
Member
 
Registered: Sep 2003
Location: chikyuu (E103N6)
Distribution: Redhat 8.0 (2.4.25-custom), Fedora Core 1 (2.4.30-custom)
Posts: 357

Original Poster
Rep: Reputation: 30
Thanks! I thought that I need to make some kind of loop for it! My script works now.
 
Old 06-02-2004, 08:27 AM   #4
sibu_rajappan
LQ Newbie
 
Registered: May 2004
Location: india
Posts: 23

Rep: Reputation: 15
hello chii-chan..........

do u remember me.................i was the one who asked for the repair of gnome and u told me to remove all the gnome files.......now i have done it but nothing like u said happened ....like the gnome is not been recreated..............

i dont have a gui now .........pls help...........

i am using rh9
 
Old 06-02-2004, 09:54 AM   #5
chii-chan
Member
 
Registered: Sep 2003
Location: chikyuu (E103N6)
Distribution: Redhat 8.0 (2.4.25-custom), Fedora Core 1 (2.4.30-custom)
Posts: 357

Original Poster
Rep: Reputation: 30
Can you go back to the original post. I'll answer your question there.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sed doesn't accept $variable in bash script chii-chan Programming 6 05-28-2005 08:07 AM
Latest Kernel script on front page, does it need to be updated to accept four digits? SBing LQ Suggestions & Feedback 1 09-09-2004 01:35 PM
script for a command that won't accept wildcard value hemp4fuel Programming 4 05-24-2004 06:30 AM
bash script to accept input ONLY until background process completes andrewstr Linux - Software 2 03-17-2004 01:02 PM
Perl: Getting a script to accept arguments JStew Programming 10 03-10-2003 07:56 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration