Skip to content

Instantly share code, notes, and snippets.

@h3llborn
Last active August 29, 2015 14:07
Show Gist options
  • Save h3llborn/dda94685d679d2ab3504 to your computer and use it in GitHub Desktop.
Save h3llborn/dda94685d679d2ab3504 to your computer and use it in GitHub Desktop.
assignment #2-q2
#!/bin/sh
# Author: Chris Niesel
# Class: Computer Science 2211A
echo "Number of arguments passed: $#"
X=0 # var used for while loop that increments every run
while [ $# -gt 0 ];do # check if we have more arguments
# check if $X number is even if so, print it
if [ `expr $X % 2` -eq 0 ]; then
echo $1
shift # move onto next argument
X=`expr $X + 1` # increment loop counter
# if not even move to next argument and increase counter
else
shift
X=`expr $X + 1`
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment