LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 08-29-2006, 03:11 PM   #1
samBl
Member
 
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:
#!/bin/bash
if [ ]
then
echo "Your first argument was $1"
echo "Your second argument was $2"
else
exit 127
fi
I need to figure out how to test to see if I have two arguments.
 
Old 08-29-2006, 03:58 PM   #2
zhangmaike
Member
 
Registered: Oct 2004
Distribution: Slackware
Posts: 376

Rep: Reputation: 31
Use $#. It contains the number of arguments.
 
Old 08-29-2006, 04:17 PM   #3
samBl
Member
 
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, 05:29 PM   #4
zhangmaike
Member
 
Registered: Oct 2004
Distribution: Slackware
Posts: 376

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

The best guide I've seen is here: http://www.tldp.org/LDP/abs/html/

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


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 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 11:53 AM
how to use bash and how to start a shell in redhat linux 9 chittico Linux - Newbie 7 06-29-2004 10:01 AM
Linux Shell Scripting using BASH Help! fooforon Programming 5 02-05-2004 09:16 AM
Whats the difference Linux Console and BASH Shell glenn69 Linux - Newbie 2 08-31-2003 03:19 PM
linux question about bash, shell ?? albina Linux - General 3 05-15-2002 01:07 AM


All times are GMT -5. The time now is 11:21 PM.

Main Menu
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