bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multi-character tab


From: Alex van den Bogaerdt
Subject: Re: multi-character tab
Date: Wed, 26 Oct 2005 19:41:39 +0200
User-agent: Mutt/1.4.1i

On Wed, Oct 26, 2005 at 10:09:04AM -0600, Bob Proulx wrote:

> Hmm...  It works for me.
> 
>   printf "one\0two\nabc\0xyz\n" | sort -t "\0" -k2,2 | tr "\000" " "
>   one two
>   abc xyz
>   printf "one\0two\nabc\0xyz\n" | sort -t "\0" -k1,1 | tr "\000" " "
>   abc xyz
>   one two

>   sort --version

address@hidden tmp]$ printf "one\0two\nabc\0xyz\n" | sort -t "\0" -k2,2 | tr 
"\000" " "
sort: multi-character tab `\0'
address@hidden tmp]$ sort --version
sort (coreutils) 5.2.1
Written by Mike Haertel and Paul Eggert.

Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
address@hidden tmp]$

> This may be a problem with the command shell trying to expand '\0'.
> What shell are you using?  Can you try the bash shell since it is
> known to work in this case?

address@hidden tmp]$ ps $$
  PID TTY      STAT   TIME COMMAND
 4694 pts/6    Ss     1:26 bash

address@hidden tmp]$ bash --version
GNU bash, version 3.00.14(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
address@hidden tmp]$

>   echo sort -t "\0"
>   sort -t \0

address@hidden tmp]$ echo sort -t "\0"
sort -t \0
address@hidden tmp]$

Of course, "sort -t \0" just expands to "sort -t 0" which means I'm using the
character zero as separator.  The modified variant:
address@hidden tmp]$ sort -t \\0
sort: multi-character tab `\0'
address@hidden tmp]$


To avoid any confusion: this is how it expands:

address@hidden tmp]$ echo -e \0\\0"\0\\0"'\0\\0' | od -tx1
0000000 30 00 00 00 00 5c 30 0a
0000010
address@hidden tmp]$ echo \0\\0"\0\\0"'\0\\0' | od -tx1
0000000 30 5c 30 5c 30 5c 30 5c 30 5c 5c 30 0a
0000015
address@hidden tmp]$

> In all cases the scheme creates the tab first and then uses it in the
> sort with a variable such as "sort -t $TAB".

Ack.  I'll stick to TAB=$(echo -ne \\t) then.  Thanks anyway for answering.

cheers
alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]