Skip to content

Instantly share code, notes, and snippets.

@jimjh
Created November 13, 2015 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimjh/db8e72699670b57d207a to your computer and use it in GitHub Desktop.
Save jimjh/db8e72699670b57d207a to your computer and use it in GitHub Desktop.
Using $@ vs $*
#!/bin/bash
# child.sh
# Prints all args.
while (( "$#" )); do
echo "arg: $1"
shift
done
#!/bin/bash
# parent.sh
# Usage:
# > ./parent.sh 0 'a b c' d e
echo '-- Using $* --'
./child.sh $*
echo '-- Using "$*" --'
./child.sh "$*"
echo '-- Using $@ --'
./child.sh $@
echo '-- Using "$@" --'
./child.sh "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment