Bash scripting - what is "$#" ?
Hi,
I'm encountering this line in a script: Code:
while [ $# -gt 0 ]; do Also if this is something I could Google, I would appreciate some good keywords to try. Being new to bash I didn't know what to look for, and symbols like $# together don't work. Cheers! |
It means the number of parameters on the command line when the script is called.
Check the link in my signature for the Bash reference. jlinkels |
Great, thanks a ton :)
Excellent reference, I'll start digesting it tonight! |
Please mark as SOLVED once you have a solution.
|
Yeah, that line basically says "while any arguments were given from command-line, do..."
And just by the way, $1, $2, $3, etc is the specific argument on the command-line, e.g arg1, arg2, arg3, and so on. And $@ is the entire string of arguments, e.g. "arg1 arg2 arg3 arg4" and so on. |
All times are GMT -5. The time now is 11:35 PM. |