From 09c56f7b2b00a492829bce097f2adf827535c17f Mon Sep 17 00:00:00 2001 From: "alexis.dereeper_ird.fr" <alexis.dereeper@ird.fr> Date: Sat, 23 Nov 2024 16:59:57 +0000 Subject: [PATCH] Update bash-9-scripting.md --- docs/pages/bash/bash-9-scripting.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/pages/bash/bash-9-scripting.md b/docs/pages/bash/bash-9-scripting.md index 49a7d9c..3e6d4fb 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`" -- GitLab