Windows 7 Cygwin: Sort: Input File Specified Two Times

Earlier today I needed to use sort to output unique lines from a file to a new file but ran into an issue. I was attempting to use the sort command on a Windows 7 computer with Cygwin installed. Below is information on the initial error I received and then how it was resolved.

Windows sort Warning: Input File Specified Two Times


  1. C:\\Users\\alex\\Desktop>sort -n ntlm_hashes.txt > ntlm_new.txt
  2. Input file specified two times.

As you can see above when attempting to use sort to output the unique lines from the initial list of around 31,000 NTLM hashes I received an error. First I looked to make sure the proper sort was being used which ended up not being the case as shown below.

Determine The sort Command Being Used On Windows 7 With Cygwin:


  1. C:\\Users\\alex\\Desktop>which sort
  2. /cygdrive/c/Windows/system32/sort

As you can see above the Windows 7 sort command was being called before the Cygwin version. Since the commands are different this is what caused the error regarding the input file being specified twice. So instead of making things complicated I used the entire path to the Cygwin version of the sort command and was able to complete the task I needed to as shown below.

Use Full Path To Cygwin Sort Command On Windows 7:


  1. C:\\Users\\alex\\Desktop>C:\\cygwin\\bin\\sort.exe -u ntlm_hashes.txt > ntlm_new.txt
  3. C:\Users\alex\Desktop>

Nothing is output above because the output was sent to the ntlm_new.txt file instead of the shell.

Learning the bash Shell: Unix Shell Programming (In a Nutshell (O’Reilly)) (Paperback)

List Price: $34.95 USD
New From: $18.15 USD In Stock
Used from: $12.97 USD In Stock

Cross-Platform Development in C++: Building Mac OS X, Linux, and Windows Applications (Paperback)

List Price: $54.99 USD
New From: $29.29 USD In Stock
Used from: $16.96 USD In Stock