Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to input TAB character

Status
Not open for further replies.

Ambatim

Programmer
Feb 28, 2002
110
IN
I have a TAB delimited file. I want to sort the file on the second field...
I am trying to use the sort command for this...
In the sort command how can I specify/input the TAB character as the delimiter, for the flag -t.
The command I want to use is sort -t<TAB> -k2,2 <filename>
For the flag -t...how to specify/input the TAB character..?
Any ideas...?

Thanks in advance
Mallik
 
You shouldn't need any t flag??? or do you have lines with an empty first field that mess up your field numbers?

Sort Keys

A sort key is a portion of an input line that is specified by a field
number and a column number. Fields are parts of input lines that are
separated by field separators. The default field separator is a
sequence of one or more consecutive blank characters. A different field
separator can be specified using the -t flag. The tab and the space
characters are the blank characters in the C and English Language
locales.




HTH,

p5wizard
 
I tried both of them it gives error as

$ sort -t$'\t' -k2,2 t
Usage: sort [-Abcdfimnru] [-T Directory] [-t Character] [-o File]
[-y[Kilobytes]] [-z Recordsize] [-k Keydefinition]...
[[+Position1][-Position2]]... [File]...

$ sort -t$(echo "\t") -k2,2 t
Usage: sort [-Abcdfimnru] [-T Directory] [-t Character] [-o File]
[-y[Kilobytes]] [-z Recordsize] [-k Keydefinition]...
[[+Position1][-Position2]]... [File]...


Thanks in advance
Mallik
 
Thanks p5wizard....I understood and got the result...
Thanks feherke anyway..

Thanks in advance
Mallik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top