BASH while loop

#!/bin/bash
# create while loop that starts at x and ends at y
# good for creating folders

if [ $# -eq 2 ]; then #if no arguments then prompt for one<!--?prettify linenums=true?-->
  x=$1
  y=$2
else
  echo -n "Where to begin:"
  read x
  echo -n "Where to end:"
  read y
fi

while [ $x -le $y ]
do
#action
# do something here
 echo "mkdir IS4560_Week$x"
##
  ((x++)) #increment x
done
echo "All done"

Leave a Reply

Your email address will not be published. Required fields are marked *