Skip to content

Instantly share code, notes, and snippets.

@LevPewPew
Last active July 25, 2019 07:30
Show Gist options
  • Select an option

  • Save LevPewPew/dd330140ff1f347be7228ae028afef22 to your computer and use it in GitHub Desktop.

Select an option

Save LevPewPew/dd330140ff1f347be7228ae028afef22 to your computer and use it in GitHub Desktop.
bash scripting example 0, CodeCademy Exercise
#!/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