How do I do this: -$: sample.sh <INPUT>


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do I do this: -$: sample.sh <INPUT>
# 1  
Old 12-05-2009
How do I do this: -$: sample.sh <INPUT>

I apologize for the confusing title .. What I want to do is write a script that pulls specific input from the command line (after the script name) rather than from within the script.

Example:

Code:
-$: howfarbetween.sh Montreal Chicago

Where the script would run based on the inputs of the two city names.

Thanks for all help in advance!


J
# 2  
Old 12-06-2009
Not only the title, your explanation too.

Are you looking for this ?

Code:
if [ "$1" = "Montreal" -a "$2" = "Chicago" ]
then
    echo 'X Km';
else
    echo 'Y Km';
fi

# 3  
Old 12-06-2009
Quote:
Originally Posted by jmvbxx
Code:
-$: howfarbetween.sh Montreal Chicago

Where the script would run based on the inputs of the two city names.

Command-line arguments are stored in the positional parameters, $1, $2, etc..
# 4  
Old 12-06-2009
Thank you so much!

That is exactly what I was looking for!
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sample output

hi gurus , i want the command to get the output in the desired format . basically to convert columns to rows. please refer to the attachment. (3 Replies)
Discussion started by: r_t_1601
3 Replies

2. Shell Programming and Scripting

Sample Script

Below is the code. Its the 1st line of a file. How can I remove the bracket and display like below. 123 web int 1 09:30:45 2013 I dont want to use AWK or SED or PERL. I need to use only the bash shell scripting commands to do it. (3 Replies)
Discussion started by: ghosh_tanmoy
3 Replies

3. Shell Programming and Scripting

AWK sample variance

I would like to calculate 1/n In awk, I wrote the following line for the sigma summation: { summ+=($1-average)^2 } Full code: BEGIN { Print "This script calculate error estimates"; sum=0 } { sum+=$1; n++ } END { average = sum/n } BEGIN { summ=0 } { summ+=($1-average)^2 } END { print... (8 Replies)
Discussion started by: chrisjorg
8 Replies

4. UNIX for Advanced & Expert Users

Can someone help me with creating RPM sample i need ?

i know there are tons n tons of documentation out there to help me out to understand this.. but wen i read it, its to confusing for me.. i would really wish a kind hearted person on this forum can come out with a sample spec file for the example steps that i need for the RPM. This will make me... (0 Replies)
Discussion started by: bladez
0 Replies

5. Shell Programming and Scripting

Sample Practical

Hello Today I had a beautiful test to write some commands using Ubuntu, now I want to make sure of my answers to be reassured, if I had a mistake please correct me List all files details under ubuntu Desktop. my answer: cd Desktop |ls -l Navigate to your Desktop directory and... (7 Replies)
Discussion started by: S4K
7 Replies

6. UNIX for Dummies Questions & Answers

Sample scripts

Hi All' I'm a newbe, and just is started to learn unix. Where can I find a complete sample scripts? I looking for a sample scripts which log in at another unix host and and execute another script server side. Any input welcome (5 Replies)
Discussion started by: ioniCoder
5 Replies

7. Programming

Help need a sample program

Hi all, Can some one provide me a sample program which measures the performance (both latency and throughput) of TCP and UDP protocol (2 Replies)
Discussion started by: magnetpest2k7
2 Replies

8. Programming

PAM Authentication Sample

Hi, I am a Linux / Unix newbie c programmer. I have a c/c++ daemon server that will receive authentication (userid / password) from a windows client. All I want to do is authenticate the user via PAM API - i.e. user must exist on the Unix / Linux system + password must be validated. ... (1 Reply)
Discussion started by: vineshp
1 Replies
Login or Register to Ask a Question