QuickDevGuide

Home › Linux Administration & Deployment

Text Processing: grep, sed, awk & Pipes — Linux Administration & Deployment

Unix tools do one thing well and combine through pipes (), which feed one command's output into the next. Tool Job Example grep filter lines by pattern grep -i "error" app.log cut pick columns cut -d, -f1,3 data.csv sort / uniq order, de-duplicate, count sort \ uniq -c \ sort -rn sed stream edit / substitute sed 's/http:/https:/g' awk field-based processing awk '{sum+=$3} END {print sum}' tr translate characters tr 'a-z' 'A-Z' head / tail first / last lines; tail -f follows xargs turn input into arguments find . -name '.tmp' \ xargs rm jq JSON processing jq '.items[].name' Redirection > overwrite, >> append, 2> stderr, &> both, 2>&1 merge stderr into stdout, < file stdin, tee write and pass through.

Key Takeaways