Created
October 17, 2013 01:27
-
-
Save megawertz/7017879 to your computer and use it in GitHub Desktop.
Some basic bash snippets I use to introduce shell scripting to my Linux class.
This file contains 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 | |
# viewing environment variables | |
echo "The value of the home variable is: " | |
echo $HOME | |
# issue a command | |
echo "The output of the pwd command is: " | |
pwd | |
# that's boring, grab output and make it readable | |
echo "The value of the pwd command is $(pwd)" | |
# assign command output to a variable | |
output=$(pwd) | |
echo "The value of the output variable is ${output}" | |
# view data on the command line | |
echo "I saw $@ on the command line" | |
# read data from the user | |
echo "Enter a value: " | |
read userInput | |
echo "You just entered $userInput" | |
# concatenate userinput with command output | |
echo "Enter a file extension: " | |
read ext | |
touch "yourfile.${ext}" | |
# check to see if a file exists | |
if [ -d /etc/sysconfig ]; then | |
echo "That file is there and a directory" | |
else | |
echo "Not there or not a directory" | |
fi |
thanks a lot
Thanks for sharing Sir
I appreciate your work and the way you teach it is awesome. Thank you very much.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for your time!