>>105819563I've read that o'reailly book and unix powertools or maybe couple more. I never searched how to do something with awk or sed. Also I don't get the xkcd meme about not being able to recall tar flags. It's easy af. Most tools flags make sense so you just have mnemonics over what they do
examples:
tar
-c - create
-x - e(x)tract
-v - verbose
-f - file
-z - g(z)ip
-j - bzip2 (memorize)
-J - xz (memorize)
you only need to memorize these 2 flags
find
-mindepth <num>
-maxdepth <num>
-type f : files
-type d : directories
-name <expr> : like name
-iname <expr> : like name ignore case
-not -and -a -or -o : not, and, and, or, or
-print0 : use \0 instead of \n
-exec : execute a command on match
grep and other tools share the same common flags
-E - extended regex
-e - expression
-f - file
-r - recurse
-v - non matching (reverse matches) (memorize)
awk is easy
-f file
-e expression (basically optional)
-F SEPARATOR
usage: awk '<code>' FILES...
usage: <pipeline> | awk 'code'
usage: awk -f FILE.awk : execute awk program from file
you have an implicit loop
/pattern/ {<optional body for match>}: shows only lines matching the pattern
any logical condition also applies, for example
1 : true for any line, echoes
few language variables like
NF : number (of) fields in current line
NR : number (of) row aka current line
FNR : number (of) row of many files aka current line of many files
FILENAME : name of a file
FS : field separator (how fields are split into $0 .. $NF
OFS - output field separator (how fields are printed if printed like 'print "$foo" "$bar"); space is concatenation in awk
RS : record separator i.e. line separator
ORS : output record separator
$0 : all fields aka whole line
$1 : first field of line
$3 : third field of line etc
$NF : last field of line
$(NF-2) : (last field - 2) of line etc
block BEGIN : executes before file
block END : executes after file
a program doesn't need an input such program would consist of just BEGIN { }
this is enough for most