Skip to content

Instantly share code, notes, and snippets.

@h3llborn
Last active August 29, 2015 14:07
Show Gist options
  • Save h3llborn/122523c2b72932e07daf to your computer and use it in GitHub Desktop.
Save h3llborn/122523c2b72932e07daf to your computer and use it in GitHub Desktop.
assignment #2-q1
#!/bin/sh
# Author: Chris Niesel
# Class: Computer Science 2211A
# output the last argument passed to the script
# check if there are more than 0 argument
while [ $# -gt 0 ];do
# if current argument is the last one output it
if [ "$#" -eq 1 ]; then
echo $1
exit 0
# otherwise shift to the next one
else
shift
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment