mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-06-08 18:57:12 +00:00
remove mkdocs specific syntax
This commit is contained in:
parent
8d08c1964f
commit
8026e1465b
77 changed files with 1128 additions and 1128 deletions
|
@ -44,20 +44,20 @@ shebang indicating which interpreter to use
|
|||
|
||||
### Simple Command
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
[ var=value ... ] command [ arg ... ] [ redirection ... ] # [.] is optional component
|
||||
```
|
||||
|
||||
### Pipelines (commands concatenation)
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
command | file.ext # link the first process' standard output to the second process' standard input
|
||||
command |& file.ext # link the first process' standard output & standard error to the second process' standard input
|
||||
```
|
||||
|
||||
### Lists (sequence of commands)
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
command_1; command_2; ... # execute command in sequence, one after the other
|
||||
command_1 || command_2 || ... # execute successive commands only if preceding ones fail
|
||||
command_1 && command_2 && .. # execute successive commands only if preceding ones succeeds
|
||||
|
@ -65,7 +65,7 @@ command_1 && command_2 && .. # execute successive commands only if preceding on
|
|||
|
||||
### COMPOUND COMMANDs (multiple commands as one)
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
# block of commands executed as one
|
||||
<keyword>
|
||||
command_1; command_2; ...
|
||||
|
@ -108,7 +108,7 @@ We can copy file descriptors to make them share a stream. There are also many ot
|
|||
|
||||
### Redirections
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
[x]>file # make FD x write to file
|
||||
[x]<file # make FD x read from file
|
||||
|
||||
|
@ -142,7 +142,7 @@ x>&-, x<&- # close FD x (stream disconnected from FD x)
|
|||
|
||||
With Command Substitution, we effectively write a command within a command, and we ask bash to expand the inner command into its output and use that output as argument data for the main command.
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
$(inner_command) # $ --> value-expansion prefix
|
||||
command !* # !* expands to everything except the first argument in the previous line
|
||||
command !$ # refers to the last argument of the previous command
|
||||
|
@ -151,7 +151,7 @@ sudo !! # !! expands to the entire previous command
|
|||
|
||||
## Shell Variables
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
varname=value # variable assignment
|
||||
varname="$(command)" # command substitution, MUST be double-quoted
|
||||
"$varname", "${varname}" # variable expansion, MUST be double-quoted (name substituted w/ variable content)
|
||||
|
@ -188,7 +188,7 @@ Omit the pattern to match any character.
|
|||
|
||||
Only the final exit code after executing the entire list is relevant for the branch's evaluation.
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
if command_list; then
|
||||
command_list;
|
||||
elif command_list; then
|
||||
|
@ -207,7 +207,7 @@ fi
|
|||
|
||||
### Comparison Operators
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
[[ "$a" -eq "$b" ]] # is equal to
|
||||
[[ "$a" -ne "$b" ]] # in not equal to
|
||||
[[ "$a" -gt "$b" ]] # greater than
|
||||
|
@ -218,7 +218,7 @@ fi
|
|||
|
||||
### Arithmetic Comparison Operators
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
(("$a" > "$b")) # greater than
|
||||
(("$a" >= "$b")) # greater than or equal to
|
||||
(("$a" < "$b")) # less than
|
||||
|
@ -227,7 +227,7 @@ fi
|
|||
|
||||
### String Comparison Operators
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
[ "$a" = "$b" ] # is equal to (whitespace around operator)
|
||||
|
||||
[[ $a == z* ]] # True if $a starts with an "z" (pattern matching)
|
||||
|
@ -246,14 +246,14 @@ fi
|
|||
|
||||
## Commands short circuit evaluation
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
command_1 || command_2 # if command_1 fails executes command_2
|
||||
command_1 && command_2 # executes command_2 only if command_1 succeeds
|
||||
```
|
||||
|
||||
## Loops
|
||||
|
||||
```bash linenums="1"
|
||||
```bash
|
||||
for var in iterable ; do
|
||||
# command here
|
||||
done
|
||||
|
@ -261,7 +261,7 @@ done
|
|||
|
||||
## Script Hardening
|
||||
|
||||
```sh linenums="1"
|
||||
```sh
|
||||
set -o errexit # exit on error
|
||||
set -o nounset # fail on unset variable (bypass with ${VAR:-})
|
||||
set -o pipefail # file entire pipeline if one step fails
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue