Skip to content

Commit daf072a

Browse files
authored
string operators
1 parent 3872d3d commit daf072a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

learningbash.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,8 @@
6161
2 arguments
6262
```
6363
In this case, `$3` and `$4` are null. `$0` denote the name of the script, `$1` and `$2` for the given arguments, `$#` for the number of arguments.
64-
64+
65+
### String Operators
66+
- `echo ${ varname:- word }` : will print the default value `word` if varname is undefined.
67+
- `echo ${ varname:= word }` : if `varname` is undefined, print `word` and assign that value to the `varname` variable.
68+
- `echo ${ varname:?message }`: if `varname` is undefined, print `message`.

0 commit comments

Comments
 (0)