Karellism icon

simplevariables.sh (A simple variable example)

Karellism | PRO | 12/19/20 10:49:01 AM UTC (Edited) | 0 ⭐ | 264 👁️ | Never ⏰ | []
Bash |

640 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
# A simple variable example
 
myvariable=Hello
 
anothervar=Fred
 
echo $myvariable $anothervar
echo
 
sampledir=/etc
 
ls $sampledir
 
# Lines 4 and 6 - set the value of the two variables myvariable and anothervar.
# Line 8 - run the command echo to check the variables have been set as intended.
# 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.
# Line 11 - set another variable, this time as the path to a particular directory.
# Line 13 - run the command ls substituting the value of the variable sampledir as its first command line argument.

Comments