Atopic Dermatitis for Dummies
Atopic Dermatitis for Dummies
Chronic Rhinitis Unleashed
Chronic Rhinitis Unleashed
Chronic Rhinitis Unleashed
Learn Nasal Endoscopy in 21 Days
To remove all the duplicates from the list of books, use this command:
uniq my.books
Atopic Dermatitis for Dummies
Chronic Rhinitis Unleashed
Learn Nasal Endoscopy in 21 Days
If you want to print only the book titles that are not duplicated (to find out which books you have one copy of), add the -u flag, like this:
uniq -u my.books
Learn Nasal Endoscopy in 21 Days
Conversely, you might want to exclude the titles that appear only once. If so, add the -d flag, like this:
uniq -d my.books
Atopic Dermatitis for Dummies
Chronic Rhinitis Unleashed
Now let's take inventory. To summarize the list of books and add a count of the number of times each one appears in the list, add the -c flag, like this:
uniq -c my.books
2 Atopic Dermatitis for Dummies
3 Chronic Rhinitis Unleashed
1 Learn Nasal Endoscopy in 21 Days
Note that the uniq command does not sort the input file, so you may want to use the sort command to prepare the data for uniq in advance. (See the end of this section for an example.)
Here's a recap of the flags you can use with the uniq command:
-u Print only lines that appear once in the input file.
-d Print only the lines that appear more than once in the input file.
-c Precede each output line with a count of the number of times it was found.
Previous Lesson: Sorting Data
Next Lesson: Selecting Columns
Comments (most recent first)
biko (29 Jul 2010, 09:23)
it just brings the list out but doesnt merge o eliminate the duplicates and
wen i use the -c flag it just counts them all as 1.......
Bob Rankin (28 Jul 2010, 08:55)
@biko - What response do you get? I sure hope it's not "uniq is not
recognized as an internal or external command, operable program or batch
file." :-)
biko (28 Jul 2010, 07:46)
hello i tried the uniq command and it did not work alone or with either of
the flags why?
umar ayaz (27 Jun 2010, 15:58)
Excellent simple tutorial about cut
Dennis (16 Mar 2010, 09:21)
evrica! it works grate with piping :))
Dennis (16 Mar 2010, 08:49)
does uniq work for consecutive lines only?
(that means we need to sort first, isn't ?)
Bob Rankin (05 Mar 2010, 09:36)
Did you sort first?
ramya (05 Mar 2010, 06:15)
i cannot remove the duplicate entries using uniq command why?
|
|
|
![]() |
|
| <Send This Link to a Friend> <Bookmark This Page> | ||