text-processing
Filtering, transforming, and reshaping text streams
-
awk
Tested awk examples: fields and records, patterns, BEGIN/END, arrays, printf, and practical one-liners.
-
cat
Tested cat examples: joining rotated logs, numbering lines with -n and -b, and using cat -A to find the carriage returns stopping a script from running.
-
cowsay
Tested cowsay examples: piping output into it, the wrapping rules that catch people out, cowfiles and how to write one, and why -f on a download runs code.
-
cut
Tested cut examples: selecting fields with -f, character ranges with -c, custom delimiters, and the gotchas that push you toward awk instead.
-
diff
Tested diff examples: unified and context formats, directory comparison, ignoring whitespace or case, and generating a patch file with patch to apply it.
-
grep
Tested grep examples: recursive search, regex flavours, context lines, counting, scripting, and more.
-
head
Tested head examples: -n and -c, multiple files and their headers, the -n -N form that drops the last lines, and stopping a pipeline early.
-
jq
Tested jq examples: picking values out of nested JSON, filtering with select, reshaping objects, and getting raw strings back out into a shell script.
-
sed
Tested sed examples: substitution, addressing, deletion, in-place editing, and multi-command scripts.
-
sort
Tested sort examples: numeric vs lexicographic order, sorting by field with -k, human-readable sizes with -h, and checking whether a file is already sorted.
-
tail
Tested tail examples: -n and -c, the +N form that counts from the start, following a growing file with -f, and why log rotation needs -F instead.
-
tee
Tested tee examples: saving a pipeline's output while still seeing it, appending with -a, and the sudo tee trick for writing files your shell cannot.
-
tr
Tested tr examples: case conversion, deleting or squeezing character sets, the [^...] mistake, and real text-cleanup pipelines.
-
uniq
Tested uniq examples: why input must be sorted first, counting occurrences with -c, and isolating only the duplicates or only the singles.
-
wc
Tested wc examples: -l/-w/-c/-m, multi-file totals, the no-trailing-newline gotcha that undercounts lines, and pairing with grep for non-blank counts.
-
Find and replace across many files
Replace a string across a directory tree with grep -rl and sed -i, safely for filenames containing spaces, with a dry run and a backup first.