Scripting Question:
Ralph W. Reid
rreid at sunset.net
Fri Aug 26 12:19:23 EDT 2005
On Thu, Aug 25, 2005 at 11:45:25AM -0600, Dawes, Stephen wrote:
> Can someone tell me how to determine how many parameters are passed to a
> script when the script is called?
>
> For example a simple script called trythis:
> #!/bin/bash
>
> Echo -e $0
>
> And when you call the script:
> trythis 1 2 3 4 5
>
> I get the output
> trythis
>
> What I want to see is that 5 parameters were passed to the script.
>
> Any suggestions?
>
> Steve Dawes
> Phone: (403) 268-5527
> Email: SDawes at calgary.ca
Try using '$#'. For example:
echo $#
Other special variables produced and used by bash include $? (last
program exit error status), $$ (current process number), and $* (all
of the command line parameters). There might be others that do not
come to mind at this moment--see the bash man page for more info.
HTH, and have a _great_ day!
--
Ralph. N6BNO. Wisdom comes from central processing, not from I/O.
rreid at sunset.net http://personalweb.sunset.net/~rreid
...passing through The City of Internet at the speed of light!
_PI = 4 * ARCTAN (1)
More information about the Speakup
mailing list