Computer Tips - bash: How can I remove duplicate lines from a file

Date: 2013dec1 Update: 2025jul14 Language: bash OS: Linux Q. bash: 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. Just to be clear, the file will become sorted - which is a possibly unwanted side-effect. The -u option stands for "unique".