[comp.unix.questions] sort with a tab as separator

phd_ivo@gsbacd.uchicago.edu (08/17/90)

How do I indicate to sort that my field-separation character is the tab (^I)?
I know that there is a tab option (-t) in sort, but I don't know how to specify 
^I ( or \t, for that matter).. No, the default is not this tab, but any
whitespace character according to my documentation.

Thanks for any help.

/ivo welch	ivo@next.agsm.ucla.edu

phd_ivo@gsbacd.uchicago.edu (08/18/90)

I just figured out that it is my shell that actually translates tabs into
spaces.  So, now I need a way to quote a tab (no, quotation marks or
backslash quoting don't work)...

/ivo welch	ivo@next.agsm.ucla.edu

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/19/90)

In article <1990Aug17.185300.159@midway.uchicago.edu> phd_ivo@gsbacd.uchicago.edu writes:
>I just figured out that it is my shell that actually translates tabs into
>spaces.  So, now I need a way to quote a tab (no, quotation marks or
>backslash quoting don't work)...

So get a real shell:
	$ echo '   ' | od -c
	0000000  \t  \n
	0000002
	$ 

phd_ivo@gsbacd.uchicago.edu (08/19/90)

In article <13617@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes...
 
+So get a real shell:
+	$ echo '   ' | od -c
+	0000000  \t  \n

On a NeXT improved csh (and presumably on some other shells), the following
works:

	sort -t\^V^I

that is, the tab must be quoted twice: once with the backslash, and then with
the ^V (control-V) to not substitute spaces.

Once you know this, it is no big deal, of course.

/ivo welch	ivo@next.agsm.ucla.edu

guy@auspex.auspex.com (Guy Harris) (08/21/90)

>On a NeXT improved csh (and presumably on some other shells), the following
>works:

	...

>that is, the tab must be quoted twice: once with the backslash, and then with
>the ^V (control-V) to not substitute spaces.

"improved"?  Thanks, NeXT; thanks a lot.  The vanilla C shell doesn't
have this particular stupidity.  Is this a "tcsh"ism?  If so, whoever
maintains "tcsh" should seriously think about getting rid of it, 'cause
it's a crock.  "csh" is broken enough already without breaking it
further....

phd_ivo@gsbacd.uchicago.edu (08/21/90)

In article <3922@auspex.auspex.com>, guy@auspex.auspex.com (Guy Harris) writes...
 
+"improved"?  Thanks, NeXT; thanks a lot.  The vanilla C shell doesn't
+have this particular stupidity.  Is this a "tcsh"ism?  If so, whoever
+maintains "tcsh" should seriously think about getting rid of it, 'cause
+it's a crock.  "csh" is broken enough already without breaking it
+further....

Improved: it is command-line and history editing via Emacs commands that
probably screws up some of this. I am VERY GLAD that the NeXT csh has this
feature. It makes life much more pleasant. In fact, I wouldn't even consider a
shell without this feature.

/ivo welch	ivo@next.agsm.ucla.edu

richard@aiai.ed.ac.uk (Richard Tobin) (08/21/90)

In article <1990Aug21.022525.3006@midway.uchicago.edu> phd_ivo@gsbacd.uchicago.edu writes:
>Improved: it is command-line and history editing via Emacs commands that
>probably screws up some of this. I am VERY GLAD that the NeXT csh has this
>feature. It makes life much more pleasant. In fact, I wouldn't even consider a
>shell without this feature.

There is absolutely no reason why the fact that a shell has editing
facilities should cause it to substitute spaces for tabs.  If the NeXT
csh does this then it's just plain wrong.

-- Richard
-- 
Richard Tobin,                       JANET: R.Tobin@uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin

guy@auspex.auspex.com (Guy Harris) (08/22/90)

>Improved: it is command-line and history editing via Emacs commands that
>probably screws up some of this. I am VERY GLAD that the NeXT csh has this
>feature. It makes life much more pleasant. In fact, I wouldn't even consider a
>shell without this feature.

And *I* wouldn't consider a shell that turned tabs into spaces, even
though I like that kind of command-line and history editing.  "ksh" has
command-line and history editing via EMACS commands, and as I remember
it didn't have any such problems; the Bourne-again shell version here
also has command-line and history editing via EMACS commands, and *it*
doesn't have that problem. 

chris@mcc.pyrsyd.oz (Chris Robertson) (08/22/90)

If your shell munges tabs into spaces, try "sort -t'\08'" -- I just
tried it successfully on a Pyramid in the AT&T universe.  Your
mileage may vary, of course.

-- 
"Down in the dumps?  I TOLD you you'd     |    Chris Robertson
 need two sets..."                        |  chris@mcc.oz

guy@auspex.auspex.com (Guy Harris) (08/24/90)

>If your shell munges tabs into spaces, try "sort -t'\08'" -- I just
>tried it successfully on a Pyramid in the AT&T universe.  Your
>mileage may vary, of course.

You bet it will!  The vanilla S5 Bourne shell doesn't interpret escape
sequences such as that except in the "echo" command (and I don't think
it even interprets one such as yours; try '\011' instead, 8 not being a
valid octal digit), nor does any other Bourne shell version with which
I'm familiar.  The C shells with which I'm familiar don't do so, either.

What sort of shell are you using? Did Pyramid "improve" the shell by
adding this, or are you running some shell "improved" by somebody else?

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/24/90)

In article <3947@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
->If your shell munges tabs into spaces, try "sort -t'\08'" -- I just
->tried it successfully on a Pyramid in the AT&T universe.  Your
->mileage may vary, of course.
-What sort of shell are you using? Did Pyramid "improve" the shell by
-adding this, or are you running some shell "improved" by somebody else?

Some "improvement" that would be, changing an 8 to a 9.

bob@wyse.wyse.com (Bob McGowen x4312 dept208) (08/25/90)

In article <1990Aug17.022324.13925@midway.uchicago.edu> phd_ivo@gsbacd.uchicago.edu writes:
>How do I indicate to sort that my field-separation character is the tab (^I)?
>I know that there is a tab option (-t) in sort, but I don't know how to specify 
You must quote a literal tab:

	-t'	'
	  ^^^^^^  literal tab here entered with the TAB key
Bob McGowan  (standard disclaimer, these are my own ...)
Product Support, Wyse Technology, San Jose, CA
..!uunet!wyse!bob
bob@wyse.com

chris@mcc.oz (Chris Robertson) (08/30/90)

In article <3947@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
>>If your shell munges tabs into spaces, try "sort -t'\08'" -- I just
>>tried it successfully on a Pyramid in the AT&T universe.  Your
>>mileage may vary, of course.
>
>You bet it will!  The vanilla S5 Bourne shell doesn't interpret escape
>sequences such as that except in the "echo" command (and I don't think
>it even interprets one such as yours; try '\011' instead ...

Sorry, brain out to lunch when I wrote this.  Not only did I type 8 instead
of 11, but I just checked my test file and it has a typo in it.  This
definitely doesn't work.  I must admit, I *was* a bit surprised when it
seemed to.  So just ignore me while I crawl back into that handy hole in
the wall...  :-(
-- 
"Down in the dumps?  I TOLD you you'd     |    Chris Robertson
 need two sets..."                        |  chris@mcc.oz

asrap@warwick.ac.uk (Sean Legassick) (08/31/90)

In article <1990Aug19.051237.27735@midway.uchicago.edu> phd_ivo@gsbacd.uchicago.edu writes:
=In article <13617@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes...
= 
=+So get a real shell:
=+	$ echo '   ' | od -c
=+	0000000  \t  \n
=
=On a NeXT improved csh (and presumably on some other shells), the following
=works:
=
=	sort -t\^V^I
=
=that is, the tab must be quoted twice: once with the backslash, and then with
=the ^V (control-V) to not substitute spaces.
=

Okay, csh is seriously f*cked. However:

csh% echo '	' | od -c
0000000   \t  \n
0000002

tcsh% echo '^	' | od -c 	(NB: ^V needed before TAB as TAB has special
					meaning in tcsh)
0000000   \t  \n 
0000002

So *csh may not be a 'real shell' but this I'm afraid it does do (Sun-4,
SunOs 4.0.3).

---------------------------------------------------------------------------
Sean Legassick,       cuuee@uk.ac.warwick.cu  "Improbability factor of one
Computing Services    asrap@uk.ac.warwick.cu    to one. We have normality.
University of Warwick      	 	         Anything you still can't
            (the walking C obfuscator!)	 	  handle is your own problem."