I am actually writing a batch script and I need to remove duplicate lines using either batch code (which was lame) , uniq, sort, sed, etc. but it CAN NOT SORT the list in the process. Any ideas ?
sort <file> | uniq
works great but it sorts my already sorted file. Any ides ?
cat <file> | uniq
fails.
If your file is already sorted, you can use uniq command as you gave the example of, i.e.,
cat | uniq
sort is not a requirement for uniq, it is highly advised because it only eliminates successive duplicates. if a line repeats on line numbers 2,3,4,8, without sort command in the pipe, lines 2 and 8 will be in the output. With sort only line 2 will be on the output.
Hope this is what you are asking