Last active
July 25, 2019 07:30
-
-
Save LevPewPew/dd330140ff1f347be7228ae028afef22 to your computer and use it in GitHub Desktop.
bash scripting example 0, CodeCademy Exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # script that takes in a single argument and greets you | |
| # as many times as the number given. | |
| echo "learning how to script yo" | |
| first_greeting="Nice to meet you!" | |
| later_greeting="How are you?" | |
| greeting_occasion=0 | |
| greeting_limit=$1 | |
| while [ $greeting_occasion -lt $greeting_limit ] | |
| do | |
| if [ $greeting_occasion -lt 1 ] | |
| then | |
| echo $first_greeting | |
| else | |
| echo $later_greeting | |
| fi | |
| greeting_occasion=$((greeting_occasion + 1)) | |
| done | |
| # example of putting the output of a command | |
| # into a variable. unrelated to above. | |
| cmd_var=$(pwd) | |
| echo $cmd_var |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment