Shell Scripting: get unique items in a file
The question is based on the function uniq unless you h开发者_StackOverflow社区ave some other suggestion.
I have a file which has only one column with n number of rows, and contains redundant names of items randomly.
I have tried command uniq filename>filename2 to get the unique items in filename2... but it doesn't work. I still get the same list.
Any suggestions as to how I can tackle this problem?
Thank you in advance.
Try sort -u
. uniq
only filters out repeated lines, not duplicate lines spread out over the input.
Try sort -u filename > filename2
精彩评论