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
- C:\\Users\\alex\\Desktop>sort -n ntlm_hashes.txt > ntlm_new.txt
- 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:
- C:\\Users\\alex\\Desktop>which 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:
- C:\\Users\\alex\\Desktop>C:\\cygwin\\bin\\sort.exe -u ntlm_hashes.txt > ntlm_new.txt
Nothing is output above because the output was sent to the ntlm_new.txt file instead of the shell.