[Linux-Discussion] Re: what does the variable $1 mean in Bourne shell?

  • From: "David Bruce Jr" <dbartbruce@xxxxxxxx>
  • To: <linux-discussion@xxxxxxxxxxxxx>
  • Date: Tue, 18 Dec 2001 18:40:19 -0500

 I think I found an explanation in one of my books

in a shell script:

$# means "the number of variables"

$1 means "assign this value to a variable, so later on in the shell script
all you
gotta do is use $1 and you don't have to write the whole file name"

I think

What does $? mean?

many thanks
David

----- Original Message -----
From: "Adrian Corbuleanu" <acorbuleanu@xxxxxxxxxxxxx>
To: <linux-discussion@xxxxxxxxxxxxx>
Sent: Tuesday, December 18, 2001 6:24 PM
Subject: [Linux-Discussion] Re: what does the variable $1 mean in Bourne
shell?


>
> > I know what the variable $# means in Bourne shell
> >
> > what does $1 mean?
> >
> > thanks
> > David
>
> It's the first argument in the command line. I.e.:
>
> You can do write a script called "myifconfig"
>
> ifconfig eth0 $1 netmask $2
>
> Then chmod u+x myifconfig and run
>
> #./myifconfig 192.168.1.1  255.255.255.0
>
> The last line will be equivalent to
>
> #ifconfig eth0  192.168.1.1 netmask 255.255.255.0
>
> Regards,
>
> --
> Adrian Corbuleanu
> Astrocom Corp- Engineering
> 763-694-6462
>
>


Other related posts: