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
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
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
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
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 != '' ] ;
5 matches
Mail list logo