4

I have installed Cygwin on my machine and I would to know if there exist a way to use full power of sort command also with the normal DOS prompt.

I have read this question: Unix Sort with Tab Delimiter and the command to sort a tabbed file using the second column is:

sort -t $'\t' -k 2 file.txt

If I launch the command inside the Cygwin environment it works like expected, if I launch it from the normal Windows prompt (I have renamed sort.exe into xsort.exe to avoid conflicting with native Windows sort command) it doesn't works, it not recognize the $ operator and it see \t like two distinct characters and operation fails.

Is it possible to make it working also from the DOS prompt?

Community
  • 1
  • 1
gialloporpora
  • 199
  • 2
  • 11

2 Answers2

2

This is regulated by PATH environment variable.

Under DOS prompt run the following:

echo %PATH%

You will see the path C:\cygwin\bin after c:\Windows\system32.

This means that Windows's sort.exe will be used for command sort.

You will need to edit environment variable PATH for your Windows to move c:\cygwin\bin to the left of C:\Windows\system32.

Don Cruickshank
  • 5,641
  • 6
  • 48
  • 48
  • Thanks for your reply, but I already know this. The problem is when I must specify a tab character for sorting tabbed files by second colun. – gialloporpora Jul 02 '13 at 18:49
1

Try this (in Windows a tab is '^t' rather than '\t'):

sort -t'^t' -k2 file.txt
cwarny
  • 997
  • 1
  • 12
  • 27