printf '%s
' file1 file2 file3 | xargs rm`xargs` is often used when one command produces a list of items and another command needs them as arguments.
Build practical shell pipelines, batch commands with xargs, compare files, and split or reshape data.
Turn input lines into command arguments safely and efficiently.
printf '%s
' file1 file2 file3 | xargs rm`xargs` is often used when one command produces a list of items and another command needs them as arguments.
Handle spaces and special characters safely.
find . -type f -print0 | xargs -0 rmPrefer `-print0` plus `xargs -0` for safe file-name handling.
printf '%s
' a b c | xargs -n 1 echo item:`-n 1` is useful for debugging and command isolation.
printf '%s
' app1 app2 | xargs -I{} kubectl logs {}`-I{}` substitutes each input item wherever the placeholder appears.
printf '%s
' url1 url2 url3 | xargs -n 1 -P 4 curl -I`-P` can speed up independent network or file operations.
Break large files into smaller pieces.
split -l 1000 bigfile.txt chunk_Useful for processing or shipping large text files in smaller pieces.
split -b 50M archive.log log_Size-based splitting is common when moving large files through constrained systems.
split -d -l 1000 bigfile.txt chunk_Numeric suffixes can be easier to sort and reason about than alphabetic ones.
Break a file at repeated pattern boundaries.
csplit -f part_ report.txt '/^SECTION:/' '{*}'`csplit` is powerful when file structure is driven by heading markers or section delimiters.
Compare files and inspect textual differences.
diff -u old.conf new.confUnified diff format is the most common comparison output for reviews and patches.
Find differences across two directory trees.
diff -ruN dir1 dir2A common way to inspect configuration or source tree differences.
cmp file1.bin file2.bin`cmp` is simpler than diff when you only need to know whether files differ and where the first difference occurs.
sdiff file1.txt file2.txtSide-by-side comparison is useful for quick visual inspection.
Real-world pipelines for logs, configs, code, and reports.
grep ERROR app.log | sort | uniq -c | sort -nr | headOne of the most useful Linux text-processing recipes for logs and incident triage.
Remove comments and blank lines from a config file.
grep -Ev '^[[:space:]]*($|#)' nginx.confThis makes configuration files much easier to inspect quickly.
Compute the total of a numeric CSV field after skipping the header.
awk -F, 'NR>1 {sum += $3} END {print sum}' sales.csvGreat for quick ad hoc analysis without opening a spreadsheet.
find . -type f -printf '%s %p
' | sort -nr | head -20Useful for disk cleanup and packaging investigations.
grep -Eo '([0-9]{1,3}.){3}[0-9]{1,3}' access.log | sort -uA fast shell approach for rough IP extraction from logs.
Search files first, then edit in place.
rg -l 'old-service-name' . | xargs sed -i 's/old-service-name/new-service-name/g'A practical codebase refactor pattern when you understand the scope of the match set.