2

I am using GNU sort (from GnuWin32) on Windows. I renamed it to "sort1.exe". The input text file has spaces and tabs but the fields are delimited by tabs. I tried with:

sort1 -n -k2 -t "\t" file.txt

but it says: "sort1: multi-character tab '\t'

the text looks like

lazy dog<TAB>123
fox<TAB>1
white tail wolf<TAB>11
blue bear<TAB>7

and the output should be like

fox<TAB>1
blue bear<TAB>7
white tail wolf<TAB>11
lazy dog<TAB>123

I tried using the advice in the other thread but it doesn't work in Windows.

Community
  • 1
  • 1
BearCode
  • 2,734
  • 6
  • 34
  • 37

2 Answers2

2

There's another alternative. I'm not 100% sure this is Windows compatible but you can try this way to type in a TAB character:

ctrl-v,Tab

  1. Press ctrl-v (release)
  2. Press the Tab

So you'd type the following:

sort1 -n -k2 -t "ctrl-v,Tab" file.txt

You should see that a tab is inserted between the quotes.

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
rwlaschin
  • 21
  • 2
-1

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

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