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/05/27 11:57] – 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 72: | Line 88: | ||
| * '' | * '' | ||
| * ''< | * ''< | ||
| + | |||
| + | ===== Redirection ===== | ||
| + | [[http:// | ||
| + | * Diriger plusieurs lignes vers un fichier :<code bash>/ | ||
| + | text1 | ||
| + | text2 | ||
| + | text3 | ||
| + | text4 | ||
| + | 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.1401184645.txt.gz · Last modified: 2014/05/27 11:57 by ginko
