Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # don't forget about >$ chmod 755 script.sh for start >$ ./script.sh
- echo "My First Script!"
- #Variables
- VARIABLE_NAME="Value"
- echo $VARIABLE_NAME
- MY_NAME="Mikhadziuk Pavel"
- echo "Hello, I am $MY_NAME"
- VARIABLE_CURLY="Value2"
- echo "Variable in curly brackets ${VARIABLE_CURLY}"
- #LIST=${ls}
- #SERVER_NAME=${hostname}
- #User input
- #read -p "Promt Message" VARIABLE_VALUE
- read -p "Please enter your name: " NAME
- echo "Your name is $NAME"
- #Tests
- # -d FILE_NAM # True if FILE_NAM is a directory
- # -e FILE_NAM # True if FILE_NAM exists
- # -f FILE_NAM # True if FILE_NAM exists and is a regular file
- # -r FILE_NAM # True if FILE_NAM is readable
- # -s FILE_NAM # True if FILE_NAM exists and is not empty
- # -w FILE_NAM # True if FILE_NAM has write permission
- # -x FILE_NAM # True if FILE_NAM is executable
- # -z STRING # True if STRING is empty
- # -n STRING # True if STRING is not empty
- # STRING1 = STRIN2 # True if strings are equal
- # STRING1 != STRIN2 # True if strings are not equal
- # var1 -eq var2 # True if var1 is equal to var2
- # var1 -ne var2 # True if var1 not equal to var2
- # var1 -lt var2 # True if var1 is less than var2
- # var1 -le var2 # True if var1 is less than or equal to var2
- # var1 -gt var2 # True if var1 is greater than var2
- # var1 -ge var2 # True if var1 is greater than or equal to var2
- #if [ condition-is-true ]
- #then
- # command 1
- # command 2
- # ...
- # ...
- # command N
- #fi
- #if [ condition-is-true ]
- #then
- # command 1
- #elif [ condition-is-true ]
- #then
- # command 2
- #elif [ condition-is-true ]
- #then
- # command 3
- #else
- # command 4
- #fi
- #case "$VAR" in
- # pattern_1)
- # # commands when $VAR matches pattern 1
- # ;;
- # pattern_2)
- # # commands when $VAR matches pattern 2
- # ;;
- # *)
- # # This will run if $VAR doesnt match any of the given patterns
- # ;;
- #esac
- #!/bin/bash
- read -p "Enter the answer in Y/N: " ANSWER
- case "$ANSWER" in
- [yY] | [yY][eE][sS])
- echo "The Answer is Yes :)"
- ;;
- [nN] | [nN][oO])
- echo "The Answer is No :("
- ;;
- *)
- echo "Invalid Answer :/"
- ;;
- esac
- #Loops
- #for VARIABLE_NAME in ITEM_1 ITEM_N
- #do
- # command 1
- # command 2
- # ...
- # ...
- # command N
- #done
Add Comment
Please, Sign In to add comment