Print/Count Unique Words in a File Using Command Line
Here is a one-line-command used to print/count unique words in a file:
# Print
cat file_name | tr " " "\n"| sort | uniq
# Count
cat file_name | tr " " "\n" | sort | uniq -c
# tr " " "\n" used here to replace space with newline, what it does is to put every word separated by space into a line
No comments:
Post a Comment