Skip to content

Linux & shell: Text processing pipelines

4 Linux & shell commands: Text processing pipelines. Click a command to see what each part does.

Index
4 items
Click a command to see what each part does.

Text processing pipelines4

  • sort <file> | uniq -c | sort -rn | headCount duplicate lines, most frequent first

    What each part does

    1. sort <file>sort lines so duplicates sit next to each other
    2. uniq -ccollapse adjacent duplicates and prefix each with its count
    3. sort -rnsort by that number (-n numeric) in reverse order (-r)
    4. headtop 10
  • awk '{print $1}' access.log | sort | uniq -c | sort -rn | headTop client IPs in an access log

    What each part does

    1. awk '{print $1}'print the first whitespace-separated field of every line (the client IP)
    2. sort | uniq -cgroup identical IPs and count them
    3. sort -rn | headhighest counts first, top 10
  • grep -c "<pattern>" <file>; wc -l <file>Count lines / matches

    What each part does

    1. grep -ccount matching lines instead of printing them
    2. wc -lcount all lines in the file
  • sort -t: -k3,3n /etc/passwdSort a delimited file by a numeric column

    What each part does

    1. -t:fields are separated by ":"
    2. -k3,3sort key is field 3 only
    3. ncompare that key as a number

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…