Skip to content

Instantly share code, notes, and snippets.

@im-coder-lg
Created August 14, 2021 12:36
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 im-coder-lg/df15de7c6fc4419a82ebb964be006ff7 to your computer and use it in GitHub Desktop.
Save im-coder-lg/df15de7c6fc4419a82ebb964be006ff7 to your computer and use it in GitHub Desktop.
Shell Script Practice 1

Practicing Shell Scripts

So, a few days/weeks ago, I made a shell script automator. To improve that, I am making practice in shell scripts.

The entire code was tested live on code-server(thanks to @cdr for making that) on Ubuntu 20.04.02, which is Focal Fossa LTS.

It is basically some practice on If commands and some new command for input named read.

In the next few weeks, I will be practising Shell Scripts and improve the automator as well as this file. Till then, disappears

#!/bin/bash
echo "Hi! What is your name?"
echo "Name:" && read name
echo "Hi $name! How are you doing?"
echo "If you are fine, enter 'Fine'. If not, enter 'Not Fine'"
echo "How you are doing:" && read hyad
if [ "$hyad" = "Fine" ]; then
echo "Me too! I am also fine here!"
fi
if [ "$hyad" = "Not Fine" ]; then
echo "same here. Not fine at all :("
fi
echo "Would you like to update your 'apt' repositories and upgrade them if necessary?"
echo "Respond with 'yes' or 'no'"
read aptupdate
if [ "$aptupdate" = "yes" ]; then
echo "updating apt repositories. Enter your password when sudo prompts :)"
sudo apt update
echo "'apt' repositories updated. Upgrading those VIP repositories(jk but upgrade real)"
echo "Yes or no? Respond with yes or no"
read aptupgrade
if [ "$aptupgrade" = "yes" ]; then
sudo apt upgrade
fi
fi
echo "What else do you want to do? Respond with 'something more' or 'nothing'"
read choice2
if [ "$choice2" = "something more" ]; then
echo "Why not you search GitHub for fascinating projects?"
fi
if [ "$choice2" = "nothing" ]; then
echo "Stopping this process. Goodbye(for now.)"
exit
fi
# Bloopers in the code:
# else
# echo no
# fi
# echo "Me too. $hyad here."
# if [ "$hyad" = "Not Fine" ]; then
# echo "Same here dude. Not fine at all"
# if $hyad == Fine then
@im-coder-lg
Copy link
Author

If you see the bloopers, it is like:

9 year old me, a pro on QB64, tries that. 🤣 🤣 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment