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 > $ \

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 >

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 t

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 Bob Beers
On Mon, Aug 17, 2009 at 10:01 AM, Joseph L. Casale wrote: > 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

[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 t