Bash and Linux 5 · Searching and text
Count duplicate lines
Sort lines and count how often each appears, most common first.
sort file.txt | uniq -c | sort -nr
Official Bash and Linux 5 documentation
More searching and text commands
- Search file contents
- Find files by name
- Find files changed recently
- Count lines
- Replace text in a file
- Print one column
All searching and text commands · Bash and Linux 5 cheatsheet