uniq - remove duplicate lines from a sorted file
| Liunx version | BDS Mac OS X (darwin) |
uniq [option]... [input [output]]
Ignore all but one of successive identical lines from input (or standard input), writing to output (or standard output).
-u |
cat 00 11 11 2 3 4 44 44 5 uniq 00 11 2 3 4 44 5uniq -c 00 2 11 1 2 1 3 1 4 2 44 1 5 cat 00 11 11 2 3 4 44 44 5 uniq -u 00 2 3 4 5 cat 00 11 11 2 3 4 44 44 5 uniq -D 00 11 11 44 44
AUTHOR
Written by Richard Stallman and David MacKenzie. Copyright © 2002 Free Software Foundation, Inc.
uniq (coreutils) 4.5.3 October 2003 UNIQ(1)
tersified by Dennis German
uniq [-c | -d | -u] [-i] [-f n] [-s n] [input [output]]
reads the input comparing adjacent lines and writes each unique line to the output.
If input is a single dash (-) or absent, the standard input is read.
Standard output is default used for output.
Only duplicate adjacent lines are recognized, so it may be necessary to sort the file(s) first.
-d | Duplicates Only are output | ||||
-u | Unique lines only are output , i.e. lines with more than one adjacent occurance are NOT output | ||||
-c | count is prefixed to each output line | ||||
-f nIgnore the first | n fields in each input line when doing comparisons. A field is a string of non-blank characters separated from adjacent fields by blanks. Counting begins with 1, i.e., the first field is 1. | -s n
Skip the first n characters in each input line when doing comparisons. | with -f, the first n characters after the first
n fields will be skipped. Counting begins with 1, i.e., the first character is 1. When skipping Characters or Fields, outputting Duplicates only the first line with duplicate fields is output. Example: input uniq -f1 output
xxx 21 xxx 21
yyy 21
zzz 23
| -i Ignore case
| |
> cat ffff 11 11 2 3 4 44 44 5 |
LANG, LC_ALL, LC_COLLATE and LC_CTYPE environment variables affect the execution as described in environ.