bash_cheatsheet
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| bash_cheatsheet [2014/11/30 11:41] – ginko | bash_cheatsheet [2019/02/13 16:07] (current) – [Output of a shell command] ginko | ||
|---|---|---|---|
| Line 58: | Line 58: | ||
| * '' | * '' | ||
| + | ==== Work with file paths ==== | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * <code bash>~% FILE=" | ||
| + | ~% echo " | ||
| + | example | ||
| + | ~% echo " | ||
| + | example.tar | ||
| + | ~% echo " | ||
| + | tar.gz | ||
| + | ~% echo " | ||
| + | gz</ | ||
| + | ==== Output of a shell command ==== | ||
| + | * '' | ||
| + | mytimestamp=$(date ' | ||
| ===== Mastering history ===== | ===== Mastering history ===== | ||
| [[http:// | [[http:// | ||
| Line 74: | Line 90: | ||
| ===== Redirection ===== | ===== Redirection ===== | ||
| + | [[http:// | ||
| * Diriger plusieurs lignes vers un fichier :<code bash>/ | * Diriger plusieurs lignes vers un fichier :<code bash>/ | ||
| text1 | text1 | ||
| Line 80: | Line 97: | ||
| text4 | text4 | ||
| EOM</ | EOM</ | ||
| + | * Normal: | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * Append: | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * Pipes: | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | |||
| + | ==== The problem with cats ... ==== | ||
| + | |||
| + | Take a simple redirection example such as this: | ||
| + | |||
| + | '' | ||
| + | |||
| + | You've wasted a process on cat, since you could accomplish the same thing (and have it execute faster!) by doing this: | ||
| + | |||
| + | '' | ||
| + | |||
| + | ==== Sending stderr through a pipe ==== | ||
| + | |||
| + | Sending only stderr down a pipe, while having stdout still go to the screen, is an interesting trick. It can be done by passing the stdout and stderr file descriptors to temporary file descriptors, | ||
| + | |||
| + | '' | ||
| + | |||
| + | ===== Fonctions ===== | ||
| + | '' | ||
| + | |||
| + | On retrouve cette syntax au coeur de la fameuse fork bomb bash '': | ||
| + | |||
bash_cheatsheet.1417344077.txt.gz · Last modified: 2014/11/30 11:41 by ginko
