Bash Main
Seitng up defualt values with :
set default values for variables without performing any action
: ${VAR:=default_value}```
## Bash string manipulation
> **Perom replacment**
```bash
# ${parameter/pattern/string}
selected="my_session:123:456"
session_name="${selected//:/-}"
echo $session_name # Output: my_session-123-456
Delte from match to the end
Checking if the output was from stdin or as cmd args
if [[ -t 0 ]]; then
printf "this was provided from cmd args\n"
fi
if [[ ! -t 0 ]]; then
printf "this was provided from pipe\n"
fi
Printitn mulitple values
Checking the lenght of the array
Tip
Functions are the only way to change status of an existing shell
Case stament |
---|
While loop |
Bash redirecition |
[xargs_commnad]({{\< ref “posts/code_snippets/xargs_commnad.md”>}})