Skip to content

Text processing

Searching, filtering, sorting, counting and changing text, the everyday tools for logs, configuration files and the output of other commands.

Basics: Combining commands with pipes

Count and sort

  • wc


    Count lines, words and bytes.

  • sort


    Sort lines alphabetically, numerically or by column.

  • uniq


    Remove or count repeated lines.

Cut and transform

  • cut


    Cut columns or characters out of each line.

  • tr


    Replace, squeeze or delete characters.

  • column


    Format text into aligned columns.

Search and replace

  • grep


    Search and filter lines with patterns and regular expressions.

  • sed


    Replace text, delete lines and print ranges, also directly in files.

  • awk


    Evaluate text column by column: filter, count and add up.

Compare

  • diff


    Show the differences between two files or directories.

Pipelines

  • tee


    Write output to a file and the screen at the same time.

  • xargs


    Pass input lines as arguments to another command.

Structured data

  • jq


    Read, filter and format JSON data.