Skip to content

Instantly share code, notes, and snippets.

@niuage
Created August 22, 2020 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niuage/9ec29cef9b9777737830f127fed3fafa to your computer and use it in GitHub Desktop.
Save niuage/9ec29cef9b9777737830f127fed3fafa to your computer and use it in GitHub Desktop.
# Puts this code in a file (you can name it "count" or something), then give it the proper permissions with this command:
# chmod 755 count
# Then you can run it with: ./count
#!/bin/bash
echo Enter a number:
read input_number
max=$[$input_number+100]
echo You entered $input_number. Let\'s count to $max.
# initializes i to be the number the user entered
i=$input_number
# displays the current number i and then increment it for the next iteration
while [ $i -le $max ]
do
echo $i
i=$[$i+1]
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment