Bash scripting question

Roger Oberholtzer roger
Mon May 17 11:47:50 PDT 2004


# This should echo command line parameters (or function paramaeters if
# placed in a shell function), one per line.


for param in $*
do
	echo $param
done


On Mon, 26 May 2003 21:45:32 -0700
David Aikema <dhaikema at sfu.ca> wrote:

> 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
> 
> _______________________________________________
> Linux-users mailing list
> Linux-users at linux-sxs.org
> Unsubscribe/Suspend/Etc ->
> http://www.linux-sxs.org/mailman/listinfo/linux-users
> 


-- 
+????????????????????????????+???????????????????????????????+
? Roger Oberholtzer          ?   E-mail: roger at opq.se        ?
? OPQ Systems AB             ?      WWW: http://www.opq.se/  ?
? Erik Dahlbergsgatan 41-43  ?    Phone: Int + 46 8   314223 ?
? 115 34 Stockholm           ?   Mobile: Int + 46 733 621657 ?
? Sweden                     ?      Fax: Int + 46 8   302602 ?
+????????????????????????????+???????????????????????????????+



More information about the Linux-users mailing list