views:

469

answers:

3

I would like to know how to extract a list of unique lines from a text file. Preferably through Cygwin.

+4  A: 

sort -u file > new_file

Luis
+1  A: 

Your question is somewhat unclear. If you want to eliminate all duplicate lines from a text file you can do something like this:

cat file.txt | sort | uniq
bluebrother
Useless use of cat. no cookie for you either.
simon
+3  A: 

Since the original question referenced Cygwin, which is Windows specific, I'll mention that Luis' answer works just as well using the GNU utilities for Win32 sort. I use the GNU ports off a USB key when I'm working on a machine that I don't want to install Cygwin on, or downloading and installing Cygwin seems like too heavy a solution for the problem I'm trying to solve.

Grant Wagner