Awk

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

Compter les occurences:

1
awk ' {foo[$4]++} END {for (f in foo) { print f , foo[f] }}'  < test-did

Sed

Utilisation de “backreferences”:

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

Scripts bash

1
2
3
4
5
6
${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)