moves coding challenge to end of chapter
This commit is contained in:
parent
2560bf39ad
commit
7d391db0d9
|
@ -812,6 +812,38 @@ if [ "$num" -lt "300" ]; then
|
|||
fi
|
||||
```
|
||||
|
||||
## A *modern* version of `test`
|
||||
|
||||
I'll be the first to admit that the syntax of `bash` can be confusing and is rarely reader friendly.
|
||||
A nice, but brief, explication of the nuances of single and double brackets can be found in [this](https://unix.stackexchange.com/questions/306111/what-is-the-difference-between-the-bash-operators-vs-vs-vs) stack overflow post.
|
||||
The double bracket command are called [compound commands](https://www.gnu.org/software/bash/manual/html_node/Compound-Commands.html).
|
||||
|
||||
### `[[ ]]`
|
||||
|
||||
```
|
||||
waldek@debian:~$ [[ 3 = [[:digit:]] ]] ; echo $?
|
||||
0
|
||||
waldek@debian:~$ [ 3 = [[:digit:]] ] ; echo $?
|
||||
1
|
||||
```
|
||||
TODO
|
||||
|
||||
### `(( ))`
|
||||
|
||||
TODO
|
||||
|
||||
### `&&` and `||`
|
||||
|
||||
```
|
||||
waldek@debian:~$ test true == true && echo "yes sir!" || echo "nope..."
|
||||
yes sir!
|
||||
waldek@debian:~$ test true == false && echo "yes sir!" || echo "nope..."
|
||||
nope...
|
||||
waldek@debian:~$
|
||||
```
|
||||
|
||||
[Ryan's tutorials](https://ryanstutorials.net/bash-scripting-tutorial/bash-if-statements.php)
|
||||
|
||||
# Coding challenge - File information
|
||||
|
||||
Write a script that takes one argument which should be a valid file path.
|
||||
|
@ -868,37 +900,6 @@ fi
|
|||
|
||||
</details>
|
||||
|
||||
## A *modern* version of `test`
|
||||
|
||||
I'll be the first to admit that the syntax of `bash` can be confusing and is rarely reader friendly.
|
||||
A nice, but brief, explication of the nuances of single and double brackets can be found in [this](https://unix.stackexchange.com/questions/306111/what-is-the-difference-between-the-bash-operators-vs-vs-vs) stack overflow post.
|
||||
The double bracket command are called [compound commands](https://www.gnu.org/software/bash/manual/html_node/Compound-Commands.html).
|
||||
|
||||
### `[[ ]]`
|
||||
|
||||
```
|
||||
waldek@debian:~$ [[ 3 = [[:digit:]] ]] ; echo $?
|
||||
0
|
||||
waldek@debian:~$ [ 3 = [[:digit:]] ] ; echo $?
|
||||
1
|
||||
```
|
||||
TODO
|
||||
|
||||
### `(( ))`
|
||||
|
||||
TODO
|
||||
|
||||
### `&&` and `||`
|
||||
|
||||
```
|
||||
waldek@debian:~$ test true == true && echo "yes sir!" || echo "nope..."
|
||||
yes sir!
|
||||
waldek@debian:~$ test true == false && echo "yes sir!" || echo "nope..."
|
||||
nope...
|
||||
waldek@debian:~$
|
||||
```
|
||||
|
||||
[Ryan's tutorials](https://ryanstutorials.net/bash-scripting-tutorial/bash-if-statements.php)
|
||||
|
||||
# Loops - A variety of ways to perform repetitive tasks.
|
||||
|
||||
|
|
Loading…
Reference in New Issue