I'm trying to do this but I cant create the file.I enter: sort myfile.txt uniq -u | tee newfile.txt and It wont create the file automatically. What am I missing here?
Give the command to remove duplicate lines in a .txt file and save the new file as new.txt file
linux;shell script;command line
You are missing one pipe | character.Try: sort myfile |uniq -u|tee newfile.txtIf this is not working, please provide the error message you are getting.By the way, this command uniq -u eliminates all lines which have duplicates. If this is your intention, that is fine. But if you want to see one of the duplicate lines, you need to drop -u for the uniq part of this command line, i.e., sort myfile | uniq | tee newfile.txt