mirror of https://github.com/01-edu/public.git
3 changed files with 51 additions and 0 deletions
@ -0,0 +1,11 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
# Unofficial Bash Strict Mode |
||||||
|
set -euo pipefail |
||||||
|
IFS=' |
||||||
|
' |
||||||
|
|
||||||
|
submitted=$(bash student/set-internal-vars.sh) |
||||||
|
expected=$(bash solutions/set-internal-vars.sh) |
||||||
|
|
||||||
|
diff <(echo "$submitted") <(echo "$expected") |
@ -0,0 +1,8 @@ |
|||||||
|
MY_MESSAGE="Hello World" |
||||||
|
MY_NUM=100 |
||||||
|
MY_PI=3.142 |
||||||
|
MY_ARR=(one, two, three, four, five) |
||||||
|
echo $MY_MESSAGE |
||||||
|
echo $MY_NUM |
||||||
|
echo $MY_PI |
||||||
|
echo ${MY_ARR[*]} |
@ -0,0 +1,32 @@ |
|||||||
|
## set-internal-vars |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Create a script `set-internal-vars.sh`, which will allow you to create and print the following variables. |
||||||
|
|
||||||
|
- `MY_MESSAGE` which contains the string `"Hello World"`. |
||||||
|
- `MY_NUM` which contains the number `100`. |
||||||
|
- `MY_PI` which contains the number `3.142`. |
||||||
|
- `MY_ARR` which contains `(one two three four five)` |
||||||
|
|
||||||
|
Expected output: |
||||||
|
|
||||||
|
```console |
||||||
|
$ ./set-internal-vars.sh |
||||||
|
Hello World |
||||||
|
100 |
||||||
|
3.142 |
||||||
|
one, two, three, four, five |
||||||
|
$ |
||||||
|
``` |
||||||
|
|
||||||
|
### Hints |
||||||
|
|
||||||
|
Creating variables: |
||||||
|
|
||||||
|
Variables can be created either at the shell or in shell-scripts. Any variable created within a shell script is lost when the script stops executing. A variable created at the prompt, however, will remain in existence until the shell is terminated. The syntax for creating a variable is : |
||||||
|
|
||||||
|
`<variable name>=<value>` |
||||||
|
|
||||||
|
> You have to use Man or Google to know more about commands flags, in order to solve this exercise! |
||||||
|
> Google and Man will be your friends! |
Loading…
Reference in new issue