On Sun, Sep 21, 2014 at 5:14 PM, Greg Donald <[email protected]> wrote:
> On Sun, Sep 21, 2014 at 4:06 PM, andrew mcelroy <[email protected]> wrote:
>> Greetings all,
>>
>> This is probably a dumb questions, but I am writing a basic shell
>> script that is passing $@ to a command. The issue is I'd like to
>> filter $@ so that it does not pass a specific flag ( in this case
>> --xcode-dir) ? How can I drop this in a bash script?
>
> Assuming you want to drop the argument (value) after --xcode-dir as well:
>
This is what I was looking for.
I ended up going with $1 through $7 (since it is going to be the same
input and is automated).
Thanks Greg.
This should be October's "Asleep At The Prompt".
> #!/usr/bin/env bash
>
> args=("$@")
> myargs=()
> nextarg=-1
>
> for ((i=0; i<$#; i++)) {
> if [ $nextarg == $i ]; then continue; fi
> case ${args[$i]} in
> --xcode-dir) nextarg=$((i+1)) ;;
> *) myargs+="${args[$i]} "
> esac
> }
>
> echo $myargs
>
> ./remove_xcode --xcode-dir foo --bar baz
> --bar baz
>
>
> --
> Greg Donald
>
> --
> --
> You received this message because you are subscribed to the Google Groups
> "NLUG" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nlug-talk?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "NLUG" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the Google Groups
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nlug-talk?hl=en
---
You received this message because you are subscribed to the Google Groups
"NLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.