Some collected miscellaneous in bash

  • Shell expansions order: Brace Expansion, Tilde Expansion, Shell Parameter Expansion, Command Substitution, Arithmetic Expansion, Process Substitution, Word Splitting, Filename Expansion, Quote Removal.
  • List operators precedence: && is same as ||, followed by ; and &, which have equal precedence.
  • Grouping commands: ( list ) or { list; }.
    () introduces a subshell, while {} does not.
    {} requires last semicolon or newline.
    () does not require begin/end spaces, while {} does
  • GNU parallel tool to run command in parallel: -0, -j+0, j 10 are useful options
  • Command Line Editing with default emac mode
    Basic:
    C-b, C-f, C-d, C-h: move/delete one character back/forward
    C-a, C-e: move to end/begin of line
    C-l: clear screen
    M-f, M-b, C-w, M-w: move/kill word back/forward
    C-_ ( C-x C-u): undo
    C-k, C-u: kill to end/begin
    C-y, M-y: yank and rotate yank
    C-r, C-s: search back/forward
    C-g: abort
    C-n, C-p, M-<, M->: next/previous/begin/end of history
    C-v <key> (or C-q <key>): print a key
    C-d: EOF
    M-[-]<digit>: add argument
    Others:
    C-t, M-t: transpose char, word
    M-u, M-l, M-c: up/down case word, capitalize word
    M-?, M-*: show/insert possible completions
    M-/, M-~, C-x ~, M-$, C-x $, M-@, C-x @, M-!, C-x !, M-{: completion keys