a bash scripting question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You caught me away from my reference library, but essentially arguments on
the command line of a command that invokes a bash script are referenced as
$1, $2, $3, etc.

So you could, after your #!/bin/bash line, assign the arguments to your
variables like so:

VAR1 = $1
VAR2 = $2

I think.  You may need to define them as $VAR1 and $VAR2, but I'm not
sure, try it both ways and see which works.

Also, if you have more than 9 arguments on the command line, you can use
the shift command to access those beyond $9.

The man page for bash is pretty thorough, as I recall.

-- Hugh

On Wed, 6 Aug 2003, Gregory Nowak wrote:

> Hi all.
>
> Can someone please tell me how to write a bash script that would accept 2
> arguments from the command line, where the first argument would be an
> integer like 1234567, and the second argument would be a text string?
> I would then like to be able to access the variables inside the script
> via $VAR1 and $VAR2.
>
> Thanks for any help.
>
> Greg
>
>
> --
> Free domains: http://www.eu.org/ or mail dns-manager at EU.org
>
>
> _______________________________________________
> Speakup mailing list
> Speakup at braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
>




[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux