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?

  • You should probably pick one of either 'sort' or 'uniq'. That should help.
    – Thomas N
    Feb 9, 2016 at 16:57

1 Answer 1


You are missing one pipe | character.

Try: sort myfile |uniq -u|tee newfile.txt

If 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

  • worked just fine bro. I thought to add a pipe but UNIX makes you scared to second guess, second guessing yourself. Feb 9, 2016 at 18:54
  • 1
    Thank you @MelBurslan for your comment about uniq -u May 18, 2018 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .