Where to start First steps track · 15 stages
Linux Labs

wc — count lines, words and bytes

cheat sheet · Ubuntu 24.04 · GNU coreutils 9.4 https://lab.dimsanych.ru/en/wiki/wc/

Cheat sheet

  • wc file.txt lines, words, bytes and the name
  • wc -l file.txt lines only: "2 file.txt"
  • wc -l < file.txt just the number: "2"
  • grep error app.log | wc -l how many lines contain error
  • wc -l *.log per file, plus a total
  • find /etc -name '*.conf' | wc -l how many files were found
  • wc -m text.txt characters, not bytes

Options

Options combine: wc -lw prints lines and words. The full list is in man wc.

Loading…