diff --git a/docs/pages/bash/bash-9-scripting.md b/docs/pages/bash/bash-9-scripting.md index 49a7d9caf4c4d496c686717ae0473486c46c3f0f..3e6d4fb5220d88b9dc7f9313f65ae698786d911f 100644 --- a/docs/pages/bash/bash-9-scripting.md +++ b/docs/pages/bash/bash-9-scripting.md @@ -13,6 +13,29 @@ echo hello # how are you? my command ls ; cd When it will come the time to write scripts, you will have to use it extensively to comment your code... +## Variable + +A variable is a named storage location that holds a value or information. Think of a variable as a container. The name of the variable allows you to refer to and access the stored value. + +In bash any character or string can become a variable storing any value using the = sign as follow: + +```bash +v=hello +var=4 +echo $v +echo $var +``` + +!!! question "Try to define a variable `number` and initialize it to 10. Display the value of the variable with `echo`. Change its value to 20 and display it" + +??? example "Click to show the solution" + ```bash + number=10 + echo $number + number=20 + echo $number + ``` + ## First script !!! question "Write a bash script called `count.sh` that allows to count the number of files contained in the directory `training_unix_basics/data`"