It was a dark and stormy night when "Bill Hinds"
Anybody know of a utility that will remove duplicate lines in a
sorted text file? For instance, if I have...
abcd
abcd
abcd
...it would remove two lines.
If you don't mind using command line tools you can use Uniq:
<Quote>
Usage: Uniq. [OPTION] ... [INPUT [OUTPUT]]
Discard all but one of successive identical lines from INPUT (or
standard input), writing to OUTPUT (or standard output).
Options:
-c -or- --count
Prefix lines by the number of occurrences.
-d -or- --repeated
Only print duplicate lines.
-D -or- --all-repeated[=delimit-method]
Print all duplicate lines delimit-method={none
(default),prepend,separate} Delimiting is done with blank lines.
-f -or- --skip-fields=N
Avoid comparing the first N fields.
-i -or- --ignore-case
Ignore differences in case when comparing.
-s -or- --skip-chars=N
Avoid comparing the first N characters.
-u -or- --unique
Only print unique lines.
-w -or- --check-chars=N
Compare no more than N characters in lines.
--help
Display this help and exit
--version
Output version information and exit
A field is a run of whitespace, then non-whitespace characters.
Fields are skipped before chars.
Report bugs to <
[email protected]>.
</Quote>
Uniq is part of the 'UnxUtils' package:
<
http://unxutils.sourceforge.net/>
Hope this helps