Rank repeated lines by frequency
Build a paste-ready command, then review its compatibility and effects before running it.
sort <file> | uniq -c | sort -nr | head -<count>Complete required fields to copy the generated command.
read-onlyno known side effects Compatibility
Linux + macOSVerified for Linux, macOS using bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementssortsort must be installed and available on PATH.
Version supportsort Current supported releasesVerified for linux, macos using bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals842 Mozilla/5.0Representative successful output; values vary with the selected target and system state.
Known errorssort: command not foundsort is missing or is not available on PATH.
Verifysort {{file}} | uniq -c | sort -nr | head -{{count}}The output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01sortCommandRuns the sort stage of this one-liner.
02<file>ParameterA value supplied in the Fill parameters section.
03|PipelinePasses the output on the left to the command on the right.
04uniqCommandRuns the uniq stage of this one-liner.
05-cOptionConfigures uniq with the -c option.
06|PipelinePasses the output on the left to the command on the right.
07sortCommandRuns the sort stage of this one-liner.
08-nrOptionConfigures sort with the -nr option.
09|PipelinePasses the output on the left to the command on the right.
10headCommandRuns the head stage of this one-liner.
11-<count>OptionConfigures head with the -<count> option.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
sort agents.txt | uniq -c | sort -nr | head -5
Example output
842 Mozilla/5.0
219 curl/8.7.1
74 Googlebot/2.1
Illustrative output — exact values vary by system and data.
Official sources