wc
The command that counts lines, words and bytes in its input; -l gives only the line count.
In more detail
wc -l counts lines, wc -w words and wc -c bytes. When it reads from standard input, as in wc -l < file, it prints just the number, while wc -l file adds the file name. Some versions pad the number with spaces.
Examples
wc -l < names.txtgit -C fixture tag -l 'deploy-*' | wc -l # counts deployment tagsgit -C fixture tag -l 'deploy-*' | wc -lwc -c .git/refs/heads/feature prints 41: a 40-character ID and a new line.Related terms
- grep — The command that prints the lines of its input that match a pattern.
- tr — The command that replaces, squeezes or deletes single characters as text passes through it.
- git tag — A name fixed permanently to one commit, usually to mark a release such as v1.0, and the command that creates and lists them.
Taught in
- Standard Input, Output And Error — Bash Scripting & Command Line Automation
- Command Substitution And Subshells — Bash Scripting & Command Line Automation
- Exit Codes, And What Success Means — Bash Scripting & Command Line Automation
- Debugging: set -x, bash -n And Reading The Error — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation
- find And xargs — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation
- Throughput: Change Lead Time And Deployment Frequency — DevOps & Site Reliability Engineering
- A Branch Is A Moving Pointer — Advanced Git Internals & Distributed Workflows
- Sixty Questions, One Wrong Flag Each — LPIC-1 Linux Administrator (101-500 and 102-500) Exam Prep