gawk -F\t works, but when it comes to sort, it fails. Under Linux or Cygwin, $'\t' will do it. However, to input a special key Tab, no way. Can anybody figure out a way?

migrated from stackoverflow.com Aug 27 '12 at 16:11

This question came from our site for professional and enthusiast programmers.


In PowerShell, the escape character is `. A string containing a tab can be written as


Thanks to fellows from Yahoo, Baidu and Stack Overflow, this tough problem is finally solved.

sort -t":" -k1 /var/log/accessfile

This statement give me a hint.

Now the answer is a combination of all tips.

  1. cmd /f:off
  2. sort -t"  "  -k16 foobar.txt 

    (the tab character is in double quotes)

foobar.txt is a text file with the tab separation.

The key is the double quotes ("").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.