daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # don't forget about >$ chmod 755 script.sh for start >$ ./script.sh
  3. echo "My First Script!"
  4.  
  5. #Variables
  6. VARIABLE_NAME="Value"
  7. echo $VARIABLE_NAME
  8. MY_NAME="Mikhadziuk Pavel"
  9. echo "Hello, I am $MY_NAME"
  10. VARIABLE_CURLY="Value2"
  11. echo "Variable in curly brackets ${VARIABLE_CURLY}"
  12. #LIST=${ls}
  13. #SERVER_NAME=${hostname}
  14.  
  15. #User input
  16. #read -p "Promt Message" VARIABLE_VALUE
  17. read -p "Please enter your name: " NAME
  18. echo "Your name is $NAME"
  19.  
  20. #Tests
  21. # -d FILE_NAM  # True if FILE_NAM is a directory
  22. # -e FILE_NAM  # True if FILE_NAM exists
  23. # -f FILE_NAM  # True if FILE_NAM exists and is a regular file
  24. # -r FILE_NAM  # True if FILE_NAM is readable
  25. # -s FILE_NAM  # True if FILE_NAM exists and is not empty
  26. # -w FILE_NAM  # True if FILE_NAM has write permission
  27. # -x FILE_NAM  # True if FILE_NAM is executable
  28.  
  29. # -z STRING  # True if STRING is empty
  30. # -n STRING  # True if STRING is not empty
  31. # STRING1 = STRIN2 # True if strings are equal
  32. # STRING1 != STRIN2 # True if strings are not equal
  33.  
  34. # var1 -eq var2  # True if var1 is equal to var2
  35. # var1 -ne var2  # True if var1 not equal to var2
  36. # var1 -lt var2  # True if var1 is less than var2
  37. # var1 -le var2  # True if var1 is less than or equal to var2
  38. # var1 -gt var2  # True if var1 is greater than var2
  39. # var1 -ge var2  # True if var1 is greater than or equal to var2
  40.  
  41. #if [ condition-is-true ]
  42. #then
  43. #  command 1
  44. #  command 2
  45. #    ...
  46. #    ...
  47. #  command N
  48. #fi
  49.  
  50. #if [ condition-is-true ]
  51. #then
  52. #  command 1
  53. #elif [ condition-is-true ]
  54. #then
  55. #  command 2
  56. #elif [ condition-is-true ]
  57. #then
  58. #  command 3
  59. #else
  60. #  command 4
  61. #fi
  62.  
  63. #case "$VAR" in
  64. #  pattern_1)
  65. #    # commands when $VAR matches pattern 1
  66. #    ;;
  67. #  pattern_2)
  68. #    # commands when $VAR matches pattern 2
  69. #    ;;
  70. #  *)
  71. #    # This will run if $VAR doesnt match any of the given patterns
  72. #    ;;
  73. #esac
  74.  
  75. #!/bin/bash
  76. read -p "Enter the answer in Y/N: " ANSWER
  77. case "$ANSWER" in
  78.   [yY] | [yY][eE][sS])
  79.     echo "The Answer is Yes :)"
  80.     ;;
  81.   [nN] | [nN][oO])
  82.     echo "The Answer is No :("
  83.     ;;
  84.   *)
  85.     echo "Invalid Answer :/"
  86.     ;;
  87. esac
  88.  
  89. #Loops
  90. #for VARIABLE_NAME in ITEM_1 ITEM_N
  91. #do
  92. #  command 1
  93. #  command 2
  94. #    ...
  95. #    ...
  96. #  command N
  97. #done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top