Skip to content

Instantly share code, notes, and snippets.

@yingshaoxo
Last active December 12, 2022 23:26
Show Gist options
  • Save yingshaoxo/e6132a1aef09344d3f87025c6372bb28 to your computer and use it in GitHub Desktop.
Save yingshaoxo/e6132a1aef09344d3f87025c6372bb28 to your computer and use it in GitHub Desktop.
variable, function, for loop, if else
#!/bin/bash
function hi() {
#no matter what get print out, it will get returned
author=$1
echo "${author}: \n"
echo "hi,\n";
echo "you";
}
#yingshaoxo="$(echo yingshaoxo)"
yingshaoxo="yingshaoxo"
var=$(hi $yingshaoxo)
echo -e $var
echo -e $var
echo -e "\n"
my_list=("dog" "human" "cat");
for word in ${my_list[@]}; do
if [[ $word == "human" ]] ; then
echo "${word} !!!"
elif [[ $word == "dog" ]]; then
echo "$word ."
else
echo $word
fi
done
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment