Skip to main content

Text Processing & Editing

Description Commands
Daily drivers grep, sed, awk, sort, uniq, cut, tr, head, tail, wc
File comparison & patching diff, patch, comm, sdiff, diffstat
File splitting/merging split, join, paste, csplit
Formatting fmt, fold, expand, unexpand, column, indent
Editors vi, emacs, nano/pico, joe, jed, ed, ex
Special utilities look, spell/aspell/ispell, unix2dos

Daily Drivers

grep

Usage       : grep "error" logfile.txt
Example     : dmesg | grep usb
Description : Search for patterns in text files
Takeaway    : Use when you need to quickly find matching text in files or command output

sed

Usage       : sed 's/foo/bar/g' file.txt
Example     : Replace “error” with “warning” in logs.
Description : Stream editor for text substitution and inline editing.
Takeaway    : Use for automated text replacements and inline edits.

awk

Usage       : awk '{print $1,$3}' file.txt
Example     : Extract columns from CSV logs.
Description : Powerful text/data processing and reporting tool.
Takeaway    : Use for structured text manipulation and quick data analysis.

sort

Usage       : sort file.txt
Example     : sort -nr access.log
Description : Sort lines in text files
Takeaway    : Use to order data numerically or alphabetically

uniq

Usage       : uniq file.txt
Example     : sort file.txt | uniq -c
Description : Remove duplicate lines or count unique occurrences.
Takeaway    : Use to clean duplicates or count frequency.

cut

Usage       : cut -d',' -f2 file.csv
Example     : Extract usernames from /etc/passwd
Description : Extract specific columns or fields
Takeaway    : Use for column-based text extraction

tr

Usage       : tr 'a-z' 'A-Z' < file.txt
Example     : Convert lowercase to uppercase
Description : Translate, delete, or squeeze characters
Takeaway    : Use for character-level transformations
Usage       : head -n 20 file.txt
Example     : Preview top of log file
Description : Show first N lines of a file
Takeaway    : Use for quick file inspection

tail

Description : Show last N lines of a file
Usage       : tail -f logfile.txt
Example     : Monitor logs in real-time
Takeaway    : Use for log monitoring and file endings

wc

Usage       : wc -l file.txt
Example     : Count lines in a log file
Description : Count words, lines, characters
Takeaway    : Use for quick file statistics

expr

Usage       : expr 5 + 3
Example     : expr length "hello"
Description : Evaluate expressions (math, strings).
Takeaway    : Use for quick arithmetic or string ops in shell.

Tips, Tricks, Roadmaps, Resources, Networking, Motivation, Guidance, and Cool Stuff ♥

Updated on Dec 23, 2025