Bash, sed, awk

[toc]

Awk

ps ax| awk '{ print $1 " " $5 }'

Compter les occurences:
awk ' {foo[$4]++} END {for (f in foo) { print f , foo[f] }}'

Sed

Utilisation de "backreferences":
echo "abc123" | sed 's/\(.*\)\(123\)/\2\1/'

Scripts bash

${VAR:-text if $VAR is empty}
${VAR:=text if $VAR is empty and set VAR to this}
${VAR:+text if $VAR is set}
${#VAR} -> length of $VAR
${VAR#pattern} or ${VAR##pattern} -> remove match of pattern from beginning of $VAR (## -> longest match)
${VAR%pattern} or ${VAR%%pattern} -> remove match of pattern from end of $VAR (%% -> longest match)

Notes