Remove arguments

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' :wink:

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 a lot.

Albert.

Assuming I understand -
let's say your arguments are 1 2 3 4
and you want to "lose" 2 (which in this case happens to be $2).
So the args become 1 3 4

# do not include the value you want to skip -- $2
set - $1 $3 $4
# show the new arguments
echo $*

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.

Thanks a lot.

Albert

I got it:

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?

Albert.

Because awk has a special way of passing shell variables into it:

awk -v sep="$order"  'BEGIN { FS=sep }{ print $1 $2 }'

ok you have to delete -confirmed so:

set - $( echo "$*" | sed 's/-confirmed//' )

Run this - you do not have to test for -confirmed if you do not need to

Thanks a lot.

Albert.