![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
$# 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] |
|
#3
|
||||
|
||||
|
Quick Test Case (Example)
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. |
||||
| Google The UNIX and Linux Forums |