Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-29-2006, 04:11 PM   #1
Registered: May 2006
Posts: 31

Rep: Reputation: 1
Linux Bash shell Scrpt help

I'm trying to make a shell script for a class in college where it will tack to entered arguments and display them on the screen as " Your first argument was ___" and "your Second argument was ____". If more or less then two arguments are entered the program will quit.
So it I entered:
./usage.bash hi there
my out put should be:
your first argument was hi
your second argument was there.

Here is what I have so far:
if [ ]
echo "Your first argument was $1"
echo "Your second argument was $2"
exit 127
I need to figure out how to test to see if I have two arguments.
Old 08-29-2006, 04:58 PM   #2
Registered: Oct 2004
Distribution: Slackware
Posts: 376

Rep: Reputation: 31
Use $#. It contains the number of arguments.
Old 08-29-2006, 05:17 PM   #3
Registered: May 2006
Posts: 31

Original Poster
Rep: Reputation: 1
Thank you I just could not remember. Is there a good online resource that might be able to help me with my scripting?
Old 08-29-2006, 06:29 PM   #4
Registered: Oct 2004
Distribution: Slackware
Posts: 376

Rep: Reputation: 31
Go to, search for bash scripting. Google's great, too.

The best guide I've seen is here:

Honestly, just search around yourself. It's hard not to find good bash documentation.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help Compiling program (./confgure scrpt does not work) sunny000 Linux - Software 4 03-19-2006 12:53 PM
how to use bash and how to start a shell in redhat linux 9 chittico Linux - Newbie 7 06-29-2004 11:01 AM
Linux Shell Scripting using BASH Help! fooforon Programming 5 02-05-2004 10:16 AM
Whats the difference Linux Console and BASH Shell glenn69 Linux - Newbie 2 08-31-2003 04:19 PM
linux question about bash, shell ?? albina Linux - General 3 05-15-2002 02:07 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:26 AM.

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