Skip to content

Instantly share code, notes, and snippets.

@h3llborn
Last active August 29, 2015 14:07
Show Gist options
  • Save h3llborn/e44794eab5a3885bfe42 to your computer and use it in GitHub Desktop.
Save h3llborn/e44794eab5a3885bfe42 to your computer and use it in GitHub Desktop.
assignment #2-q3
#!/bin/sh
# Author: Chris Niesel
# Class: Computer Science 2211A
# get number from user
echo "Enter a number: "
read i
x=0 # loop iterator value
# check if iterator value is less than inputted value-1
while [ "$x" -lt `expr $i - 1` ]
do
s=`seq 0 $x` # generate sequence of numbers
echo $s # echo sequence of numbers
x=`expr $x + 1` # increase loop iteration counter
done
# check if iteration counter is bigger or equal to 0
while [ "$x" -ge 0 ]
do
s=`seq 0 $x` # generate sequence of numbers from 0 to iterator counter
echo $s # echo sequence of numbers
x=`expr $x - 1` # decrease loop counter
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment