In many SO questions and bash tutorials I see that I can access command line args in bash scripts in two ways:
$ ~ >cat testargs.sh
#!/bin/bash
echo "you passed me" $*
echo "you passed me" $@
Which results in:
$ ~> bash testargs.sh arg1 arg2
you passed me arg1 arg2
you passed me arg1 arg2
What is the difference between $*
and $@
?
When should one use the former and when shall one use the latter?
echo "something $@"
as an error – Alex Cohn