开发者

Shell Scripting: get unique items in a file

开发者 https://www.devze.com 2023-03-03 02:42 出处:网络
The question is based on the function uniq unless you h开发者_StackOverflow社区ave some other suggestion.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消