Index menü
Alapvető hibakezelés:
set -eufo pipefail
…
Useset -o errexit
(a.k.a.set -e
) to make your script exit when a command fails. Then add|| true
to commands that you allow to fail. Useset -o nounset
(a.k.a.set -u
) to exit when your script tries to use undeclared variables. Useset -o xtrace
(a.k.aset -x
) to trace what gets executed. Useful for debugging. Useset -o pipefail
in scripts to catchmysqldump
fails in e.g.mysqldump |gzip
. The exit status of the last command that threw a non-zero exit code is returned.… kvz.io
printf '"%b"\n' "$0" "$@" | nl -v0 -s": "
printf '%120s'
printf '%120s' | tr ' ' '='
$parameter
változó, akkor legyen lecserélve a „default” szóra: echo "${parameter='default'}"
$parameter
változó, akkor legyen lecserélve a „default” szóra: echo "${parameter:='default'}"
$param != null | $param == null | unset param |
|
---|---|---|---|
${param:-word} | $param | word | word |
${param:=word} | $param | =word | =word |
${param:?word} | $param | hiba | hiba |
${param:+word} | $param | null | null |
exec {out_fd}>/tmp/en_fajlom echo "${out_fd}" #például 10
Parancs kimenetének használata, mint fájl leíró
cat <( date )
date >( cat )
TODO:
Solution: | Component | Explanation | ------------- | --------------- | ------ | | Note | | `echo 2 >a` | Write `2` to file **a**. | Creates **a** file with `2` content | | `<(echo 3)` | Run `echo 3` command in a sub-shell and get the path of the it's stdout fd (e.g. `/dev/fd/63`). | Creates a subshell | | `exec {b}< /dev/fd/63` | ??? | ??? | | `cat -` | `cat` reads from stdin instead of a file and writes everything to stdout || | `echo 1 | cat -` | stdout of `echo 1` piped to `cat` | #1 input of `cat` | | `cat - <a` | Read **a** file into stdin of `cat` | #2 input of `cat` | | `cat - <&${b}` | ??? | #3 input of `cat` | | ``` cat - <<-EOF 4 EOF ``` | Read multiline string while `EOF` with removal of <TAB> indents | #4 input of `cat` | | `cat - <<<5` | Write `5` to stdin of `cat` | #5 input of `cat` | | `cat 2>&1` | merge stderr of cat into it's stdout | | `cat >c` | `cat` writes the input data to file **c** | creates **c** file | | `cat >|d` | `cat` writes the input data to file **d** if the **d** is not existed ??? | creates **d** file | | `cat >>e` | `cat` appends the input data to file **e** | creates **e** file |
# a szülő process megszűnésekor a parancs is leáll command & # a szülő process megszűnésekor a parancs tovább él command &! # == nohup command
# folytatás előtérben fg # folytatás háttérben bg
disown