$#

In my script let's call it myfile, I want to have an option where the script changes the time format(military to standard). But to have the script change - you run the script but instead of at the command line you type: myfile,
you type myfile -r.
Now if I remember correctly I have to include:
echo $#
in my script but is that all.(# means just one argument if I remember)
Or am I missing something, also if I had a -t -w -j option would I just use:
echo $####(for 4 arguments).
Thanks.

$# is a shell variable which holds the number of arguments you passed to your shell script. So, if you ran:
myfile -r

Then $# would be set to 1. 'echo $#' would output '1' to the screen.

[Edited by Neo on 11-27-2000 at 11:59 PM]

Create a file called 'test' with only one line in the script: echo $#

Make sure you chmod 755 test and then run:

./test

Note the results will be 0.

Then run ./test a b c

Note the results will be 3, just like PxT describes in his reply.