Skip to content

Instantly share code, notes, and snippets.

@NickTomlin
Created November 28, 2012 20:36
Show Gist options
  • Save NickTomlin/4164193 to your computer and use it in GitHub Desktop.
Save NickTomlin/4164193 to your computer and use it in GitHub Desktop.
Bash Parameter exercises
#!/bin/bash
# see http://www.ibm.com/developerworks/library/l-bash-parameters/index.html
testfunc ()
{
echo "$# parameters";
echo "{$1:}";
# if [ $1 = "@*" ]
# then
# echo "it's an @"
# exit
# fi
}
testfunc2 ()
{
echo "$# parameters";
echo Using '$*';
for p in $*;
do
echo "[$p]";
done;
echo Using '"$*"';
for p in "$*";
do
echo "[$p]";
done;
echo Using '$@';
for p in $@;
do
echo "[$p]";
done;
echo Using '"$@"';
for p in "$@";
do
echo "[$p]";
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment