uniq - 显示或移除重复的行(report or omit repeated lines)
- uniq [OPTION]... [INPUT [OUTPUT]]
- -c|--count ##在行首显示该行重复的次数
- -d|--repeated ##仅显示重复的行
- -f|--skip-fields ##忽略比较指定的栏
- -i|--ignore-case ##不区分大小写
- -s|--skip-chars ##忽略比较指定的字符位
- -u|--unique ##仅显示出现一次的行
- -w|--check-chars ##指定每行要比较的前几个字符
- --help ##显示帮助信息
- --version ##显示版本信息
- # cat >test <<EOF
- This is the first user.
- This is the first user.
- THis is the first user.
- This IS xhe first user.
- tHIS IS the first user.
- This is the first user.
- THIS IS THE FIRST USER.
- EOF
- # uniq test ##删除重复的行
- This is the first user.
- THis is the first user.
- This IS xhe first user.
- tHIS IS the first user.
- This is the first user.
- THIS IS THE FIRST USER.
- # uniq -c test ##在行首显示该行重复的次数
- 2 This is the first user.
- 1 THis is the first user.
- 1 This IS xhe first user.
- 1 tHIS IS the first user.
- 1 This is the first user.
- 1 THIS IS THE FIRST USER.
- # uniq -i -c test ##不区分大小写,计算每行重复的次数
- 3 This is the first user.
- 1 This IS xhe first user.
- 3 tHIS IS the first user.
- # uniq -s 2 -c test ##比较第二个字符,计算每行重复的次数
- 3 This is the first user.
- 1 This IS xhe first user.
- 1 tHIS IS the first user.
- 1 This is the first user.
- 1 THIS IS THE FIRST USER.
- # uniq -f 3 test ##不比较第三栏
- This is the first user.
- THIS IS THE FIRST USER.
- # uniq -d test ##显示重复的行
- This is the first user.
- # uniq -u test ##显示只出现一次的行
- THis is the first user.
- This IS xhe first user.
- tHIS IS the first user.
- This is the first user.
- THIS IS THE FIRST USER.
- # uniq -w 11 test ##删除重复的行,每行最多只比较前11个字符
- This is the first user.
- THis is the first user.
- This IS xhe first user.
- tHIS IS the first user.
- This is the first user.
- THIS IS THE FIRST USER.