Hi all,
First of all, this is my first post in this forum, so it's nice to know you. I hope not to brake any 'rule'
I'd like to know, if it's possible to remove a parameter from command line, regardless of its position? I've found a solution using shift, if it's the first argument. But, I don't know in which position the argument comes (if it comes). Any solution?
Thanks jim, that could be a good solution. I tried something else that it doesn't work, using strings.
I think it could be easier to understand if I show you my code:
ARGS=$@
confirmed=false
for order in $ARGS; do
if [ $order == "-confirmed" ]; then
confirmed=true
fi
[....]
done
When I know "-confirmed" is an argument I have to remove it from ARGS.
I tried cut in this way:
ARGS=`echo $ARGS | cut -d $order -f-�
but the delimiter must be a character. I think using sed or awk should work, but I don't know how. I'm quite new in bash programming.
ARGS=$@
confirmed=false
for order in $ARGS; do
if [ $order == "-confirmed" ]; then
confirmed=true
ARGS=`echo "$ARGS" | awk 'BEGIN { FS="-confirmed" } ; { print $1$2 }'`
continue
fi
[....]
done
But I have one more question. In awk command why it doesn't work if I replace
{ FS = "-confirmed" }
for
{ FS = "$order" }
It is supposed $order contains "-confirmed", isn't it?