[CentOS] Bash Help

2009-08-17 Thread Joseph L. Casale
I am trying to write a script that can pass cmd line args into an executable it runs, I need at least 4 args, but I need to pass the rest to it in the script if they exist. $@ doesn't help because I use the 1st and 2nd etc, so how do I elegantly handle passing args 4+ if they exist on the end of

Re: [CentOS] Bash Help

2009-08-17 Thread Joseph L. Casale
maybe you call shift (more than once) and then pass $...@? Didn't know bash had a shift! Thx! jlc ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos

Re: [CentOS] Bash Help

2009-08-17 Thread James Bensley
I can't think of the exact syntax at the minute but something like; if $# = 4 then for i = 1 to ($# - 4) echo arg number $i is $expr($i) next fi $# is the number of args passed so just pass the total number of args minus four ($~-4) That syntax is all wrong, but somebody on

Re: [CentOS] Bash Help

2009-08-17 Thread William L. Maltby
On Mon, 2009-08-17 at 19:55 +0100, James Bensley wrote: I can't think of the exact syntax at the minute but something like; if $# = 4 then for i = 1 to ($# - 4) echo arg number $i is $expr($i) next fi $ echo $* 1 2 3 4 $ \ while [ $1 != '' ] ; do echo $1 shift done 1

Re: [CentOS] Bash Help

2009-08-17 Thread Les Mikesell
William L. Maltby wrote: On Mon, 2009-08-17 at 19:55 +0100, James Bensley wrote: I can't think of the exact syntax at the minute but something like; if $# = 4 then for i = 1 to ($# - 4) echo arg number $i is $expr($i) next fi $ echo $* 1 2 3 4 $ \ while [ $1 != '' ] ;