Dave's Brain

Browse - Computer Tips - How can I remove duplicate lines from a file?

Date: 2013dec1
Language: bash
OS: Linux

Q.  How can I remove duplicate lines from a file?

A.  Use the -u option of sort:

sort -u file1 > file2
This will read file1 sort it and remove duplicate lines, placing the result in file2. The -u option stands for "unique".

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.