Bash scripting question

David Aikema dhaikema
Mon May 17 11:47:50 PDT 2004


I'm trying to loop through all of the command line parameters passed to 
a bash script.

I know that $# is the total number of command line options passed 
(well, $#+1 if you include $0, the name of the script) and that the 
individual parameters can be access as $0, $1, $2, and so on.

How can I loop through all of the given parameters though?

for ((NUM=1; NUM <= $#; NUM++))
do
	# what?
	#how can I access parameter # NUM?
done

David Aikema



More information about the Linux-users mailing list