On Sunday 20 November 2011 11:54:42 Pierre Gaston wrote: > On Sun, Nov 20, 2011 at 6:43 PM, Peng Yu <pengyu...@gmail.com> wrote: > > Hi, > > > > I don't see if there is a way to directly modify $@. I know 'shift'. > > But I'm wondering if there is any other way to modify $@. > > > > ~$ 1=x > > -bash: 1=x: command not found > > ~$ @=(a b c) > > -bash: syntax error near unexpected token `a' > > you need to use the set builtin: > set -- a b c
yep to pop items off the end: shift [n] to add items to the end: set -- "$@" a b c to add items to the start: set -- a b c "$@" to extract slices: set -- "${@:<first idx>[:<num items>]}" e.g. set -- a b c set -- "${@:2:1}" # this sets $@ to (b) with those basics, you should be able to fully manipulate $@ -mike
signature.asc
Description: This is a digitally signed message part.