sandervanvugt

bash scripting oct20

Oct 12th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. ##### showing includes
  2. [root@localhost bash-scripting]# cat mainscript
  3. #!/bin/bash
  4.  
  5. . includes
  6.  
  7. echo the color is $COLOR
  8. [root@localhost bash-scripting]# cat includes
  9. COLOR=red
  10.  
  11.  
  12. ##### SCRIPT 10 FIX
  13. #!/bin/bash
  14.  
  15. COUNTER=$1
  16. COUNTER=$(( COUNTER * 60 ))
  17.  
  18. minusone(){
  19. COUNTER=$(( COUNTER - 1 ))
  20. sleep 1
  21. }
  22.  
  23. while [ $COUNTER -gt 0 ]
  24. do
  25. echo you still have $COUNTER seconds left
  26. minusone
  27. done
  28.  
  29. [ $COUNTER = 0 ] && echo time is up && minusone
  30. [ $COUNTER = "-1" ] && echo you now are one second late && minusone
  31.  
  32. while true
  33. do
  34. echo you now are ${COUNTER#-} seconds late
  35. minusone
  36. done
  37.  
  38.  
  39. #### HISTORY
  40. root@localhost bash-scripting]# history
  41. 1 yum install -y git vim bash-completion
  42. 2 git clone https://github.com/sandervanvugt/bash-scripting
  43. 3 history
  44. 4 ls
  45. 5 cd bash-scripting/
  46. 6 ls
  47. 7 vim script1
  48. 8 vim ~/.vimrc
  49. 9 vim script1
  50. 10 vim ~/.vimrc
  51. 11 vim script1
  52. 12 ls /etc/hosts
  53. 13 echo $?
  54. 14 ls kejrhgkehrkhb
  55. 15 echo $?
  56. 16 vim script1
  57. 17 script1
  58. 18 echo $PATH
  59. 19 ./script1
  60. 20 ls -l
  61. 21 chmod +x s*
  62. 22 ls -l
  63. 23 ./script1
  64. 24 echo $?
  65. 25 pwd
  66. 26 echo $PATH
  67. 27 PATH=$PATH:$(pwd)
  68. 28 script1
  69. 29 echo $PATH
  70. 30 history
  71. 31 vim script2
  72. 32 script2
  73. 33 pwd
  74. 34 cat script2
  75. 35 source script2
  76. 36 cd bash-scripting/
  77. 37 vim script2
  78. 38 source script2
  79. 39 pwd
  80. 40 cd -
  81. 41 . script2
  82. 42 cd -
  83. 43 yum install -y network-scripts
  84. 44 ls
  85. 45 vim mainscript
  86. 46 vim includes
  87. 47 chmod +x mainscript
  88. 48 ./mainscript
  89. 49 vim includes
  90. 50 ./mainscript
  91. 51 cat mainscript
  92. 52 cat includes
  93. 53 cd /etc/init.d/
  94. 54 ls
  95. 55 history | head
  96. 56 vim network
  97. 57 cd /etc/sysconfig/
  98. 58 ls
  99. 59 ls -l
  100. 60 vim rsyslog
  101. 61 cd
  102. 62 cd bash-scripting/
  103. 63 history
  104. 64 file /usr/bin/passwd
  105. 65 file /etc/hosts
  106. 66 script1
  107. 67 file script1
  108. 68 grep COUNT *
  109. 69 ./countdown 12
  110. 70 vim script3
  111. 71 ./script3 a b c d e f g h i j k l
  112. 72 cat script3
  113. 73 /root/bash-scripting/script3 a b c d e f g h i j k l
  114. 74 true --help
  115. 75 false --help
  116. 76 vim script4
  117. 77 ./script4 a b c d e
  118. 78 cat script4
  119. 79 vim ex5min.txt
  120. 80 ./countdown 4
  121. 81 vim ex5.sh
  122. 82 bash ex5.sh bob bill joan
  123. 83 cat ex5.sh
  124. 84 ls
  125. 85 vim script5
  126. 86 vim script6
  127. 87 ./script6 /usr/bin/blah
  128. 88 vim script6
  129. 89 ./script6 /usr/bin/blah
  130. 90 ./countdown 12
  131. 91 ls
  132. 92 vim script7
  133. 93 which sed
  134. 94 ls -l /bin/sed
  135. 95 ls -l /bin/awk
  136. 96 ls -l /bin/gawk
  137. 97 help
  138. 98 vim script7
  139. 99 vim script6
  140. 100 history | grep PATH
  141. 101 vim script5
  142. 102 cd /lib/modules
  143. 103 ls
  144. 104 ls -l
  145. 105 uname -r
  146. 106 cd `uname -r`
  147. 107 cd ..
  148. 108 cd $(uname -r)
  149. 109 cd
  150. 110 cd bash-scripting/
  151. 111 vim script5
  152. 112 vim script8
  153. 113 cut -d : -f 1 /etc/passwd
  154. 114 vim script8
  155. 115 useradd alexander
  156. 116 useradd alex
  157. 117 useradd xander
  158. 118 ./script8 alex
  159. 119 ./script8 lex
  160. 120 cat script8
  161. 121 cut -d : -f 1 /etc/passwd | grep alex >/dev/null && echo alex exists
  162. 122 cut -d : -f 1 /etc/passwd | grep bea >/dev/null && echo alex exists
  163. 123* cut -d : -f 1 /etc/passwd | grep bea >/dev/null || echo
  164. 124 cut -d : -f 1 /etc/passwd | grep alex >/dev/null && echo alex exists || echo alex does not exist
  165. 125 vim ex6.sh
  166. 126 chmod +x ex6.sh
  167. 127 ./ex6.sh lex
  168. 128 ./ex6.sh alex
  169. 129 cat ex6.sh
  170. 130 man test
  171. 131 vim script9
  172. 132 ./script9
  173. 133 echo $?
  174. 134 ./script9 hello
  175. 135 vim script10
  176. 136 vim countdown
  177. 137 ./countdown 1
  178. 138 vim hv.sh
  179. 139 chmod +x hv.sh
  180. 140 ./hv.sh 1
  181. 141 bash -x hv.sh 1
  182. 142 vim hv.sh
  183. 143 ./hv.sh
  184. 144 ./hv.sh 1
  185. 145 vim hv.sh
  186. 146 ./hv.sh 5
  187. 147 ./countdown 1
  188. 148 echo $(( 4 + 4 ))
  189. 149 echo $( 4 + 4 )
  190. 150 ls $(which passwd)
  191. 151 [ -f /etc/passwd ] && echo it exists
  192. 152 [-f /etc/passwd] && echo it exists
  193. 153 ls /etc/hosts
  194. 154 ls/etc/hosts
  195. 155 ./countdown 12
  196. 156 vim script10
  197. 157 ./script10 1
  198. 158 wc script10
  199. 159 bash -x script10
  200. 160 vim script10
  201. 161 ./script10 1
  202. 162 vim script10
  203. 163 ./script10 1
  204. 164 bash -x ./script10 1
  205. 165 vim script10
  206. 166 ./script10 1
  207. 167 vim script10
  208. 168 ./script10 5
  209. 169 vim script10
  210. 170 ls
  211. 171 vim kube-setup.sh
  212. 172 cd ..
  213. 173 git clone https://github.com/sandervanvugt/ckad
  214. 174 cd ckad
  215. 175 vim kube-setup.sh
  216. 176 hostnamectl
  217. 177 vim kube-setup.sh
  218. 178 ./kube-setup.sh
  219. 179 cd ../bash-scripting/
  220. 180 ls
  221. 181 cat rene
  222. 182 vim rene
  223. 183 ./rene
  224. 184 cd /etc/init.d/
  225. 185 vim network
  226. 186 cd
  227. 187 cd bash-scripting/
  228. 188 ./countdown 5
  229. 189 history
  230.  
Add Comment
Please, Sign In to add comment