Karellism

simplevariables.sh (A simple variable example)

Dec 17th, 2020 (edited)
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.64 KB | None | 0 0
  1. #!/bin/bash
  2. # A simple variable example
  3.  
  4. myvariable=Hello
  5.  
  6. anothervar=Fred
  7.  
  8. echo $myvariable $anothervar
  9. echo
  10.  
  11. sampledir=/etc
  12.  
  13. ls $sampledir
  14.  
  15. # Lines 4 and 6 - set the value of the two variables myvariable and anothervar.
  16. # Line 8 - run the command echo to check the variables have been set as intended.
  17. # Line 9 - run the command echo this time with no arguments. This is a good way to get a blank line on the screen to help space things out.
  18. # Line 11 - set another variable, this time as the path to a particular directory.
  19. # Line 13 - run the command ls substituting the value of the variable sampledir as its first command line argument.
Advertisement
Add Comment
Please, Sign In to add comment