Skip to content

Linux Text Processing Commands

Linux command-line text processing usually combines small tools through pipelines. The most commonly used tools are:

  • cat: print file content.
  • grep: filter lines by pattern.
  • sed: edit text streams.
  • awk: process structured text by fields.
  • cut: extract columns from each line.
  • sort: sort lines.
  • uniq: remove or count adjacent duplicate lines.
  • tr: translate or delete characters.

Example pipeline:

cat access.log | grep "ERROR" | awk '{print $1}' | sort | uniq -c

This command filters error lines, extracts the first field, sorts the result, and counts repeated values.

REF

[1]. Shell字符串截取