views:

79

answers:

1

What is the simplest way to grab all the given arguments for a bash script and pass them all into another command within the script? For example:

Command Line:

./runProgram.sh [ARGS HERE]

Script:

#! /bin/bash
cd bin/
java com.myserver.Program [ARGS HERE]
+10  A: 

For bash and other Bourne-like shells:

java com.myserver.Program "$@"
Chris Johnsen
Well that is a nice trick to know! I'll flag this as 'Correct' as soon as SO let's me :)
Urda
Does this work for c-shell?
Amir Rachum
@Amir: No, not for *csh*. For everyone’s sanity: [do not script csh](http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/). But I think maybe `$argv:q` will work in some csh variants.
Chris Johnsen
@Chris: Nice Article!
Urda