Coreutils - gwenn/hypomnemata GitHub Wiki

Pretty-print CSV file headers

head -n 1 | tr ';' '\n' | nl

Zhead

zcat $1 | head -1

Log & print

... |& tee my.log | less

Intersection

# Works with sorted files
comm -1 -2 one_file other_file

Find duplicates

... | sort | uniq -d

Disk usage

du -h --max-depth=1
du -s * | sort -n
du -h --max-depth=1 | awk '{printf "%s %08.2f\t%s\n", index("KMG", substr($1, length($1))), substr($1, 0, length($1)-1), $0}' | sort -r | cut -f2,3

Numbering

nl -v0 # first line is 0
nl -ba # blank lines are numbered too