Thursday, March 18, 2010

pass entire parameters in shell scripts

example bash file:

save the following in a file called
echo "$@"
and then :
chmod +x
./ hello world
Note that, all the parameters you pass to will be passed to echo, this because of "$@"


SoCRaT said...

One question: Do you mean that in the above example you passed 2 parameters "hello" and "world"?

Mohammed Hewedy said...

Try this
echo "$1"

and then:
./ hello world
The result will be just "hello"