Skip to content
Snippets Groups Projects
Commit 09c56f7b authored by alexis.dereeper_ird.fr's avatar alexis.dereeper_ird.fr
Browse files

Update bash-9-scripting.md

parent cc943c6e
No related branches found
No related tags found
No related merge requests found
Pipeline #39832 passed
...@@ -13,6 +13,29 @@ echo hello # how are you? my command ls ; cd ...@@ -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... 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 ## 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`" !!! question "Write a bash script called `count.sh` that allows to count the number of files contained in the directory `training_unix_basics/data`"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment