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.txtlines, words, bytes and the name -
wc -l file.txtlines only: "2 file.txt" -
wc -l < file.txtjust the number: "2" -
grep error app.log | wc -lhow many lines contain error -
wc -l *.logper file, plus a total -
find /etc -name '*.conf' | wc -lhow many files were found -
wc -m text.txtcharacters, not bytes
Options
Options combine: wc -lw prints lines and words. The full list is in man wc.