On Saturday 22 March 2008 21:38:46 Nicholas Robinson wrote:
> On Saturday 22 March 2008 21:18:11 Amadeus W.M. wrote:
> > You would think specifying tab as a field separator for sort would work
> > like this:
> >
> > cat file | sort -k 3 -t " "
> >
> > It doesn't:
> >
> > sort: multi-character tab ` '
> >
> >
> > So after a little search and some trial and error I got this to work:
> >
> > cat file | sort -k 3 -t "`/bin/echo -e ' '`"
> >
> >
> > For my own curiosity, can someone please illuminate me as to why the
> > first incantation does not work as expected? Is there a more natural way
> > to specify other than echo?
>
> Take the double quotes out in your first attempt. So command becomes
>
> cat file | sort -k 3 -t
>
> Nick
Sorry, I was a little bit quick off the mark. The doesn't yield a tab
character (see below) as you were implying and I went along with in the first
example! If you take the double quotes out as I suggested, then the field
separator becomes the character t!
I think (being a little more cautious this time!) that you want:
followed by Ctrl V followed by Ctrl I
If I remember correctly, sort interprets a tab as a default field separator
anyway.
As to the why: it is because the -t takes an argument which is a character.
Putting double quotes around it stops the being elided and so as two
characters and t are presented to sort which is expecting only one
character. Hence its moan. Try echo " " and you will see what I mean.
In my second attempt above, the Ctrl V stops the tab character (Ctrl I) being
expanded on the command line and the joins the tab character to the t.
HTH
Nick
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
03-22-2008, 10:49 PM
"Amadeus W.M."
sort with tab field separator
On Sat, 22 Mar 2008 23:06:54 +0000, Nicholas Robinson wrote:
> On Saturday 22 March 2008 21:38:46 Nicholas Robinson wrote:
>> On Saturday 22 March 2008 21:18:11 Amadeus W.M. wrote:
>> > You would think specifying tab as a field separator for sort would
>> > work like this:
>> >
>> > cat file | sort -k 3 -t " "
>> >
>> > It doesn't:
>> >
>> > sort: multi-character tab ` '
>> >
>> >
>> > So after a little search and some trial and error I got this to work:
>> >
>> > cat file | sort -k 3 -t "`/bin/echo -e ' '`"
>> >
>> >
>> > For my own curiosity, can someone please illuminate me as to why the
>> > first incantation does not work as expected? Is there a more natural
>> > way to specify other than echo?
>>
>> Take the double quotes out in your first attempt. So command becomes
>>
>> cat file | sort -k 3 -t
>>
>> Nick
>
> Sorry, I was a little bit quick off the mark. The doesn't yield a tab
> character (see below) as you were implying and I went along with in the
> first example! If you take the double quotes out as I suggested, then
> the field separator becomes the character t!
>
> I think (being a little more cautious this time!) that you want:
>
> followed by Ctrl V followed by Ctrl I
>
> If I remember correctly, sort interprets a tab as a default field
> separator anyway.
>
> As to the why: it is because the -t takes an argument which is a
> character. Putting double quotes around it stops the being elided and
> so as two characters and t are presented to sort which is expecting
> only one character. Hence its moan. Try echo " " and you will see what
> I mean.
>
> In my second attempt above, the Ctrl V stops the tab character (Ctrl I)
> being expanded on the command line and the joins the tab character to
> the t.
>
> HTH
>
> Nick
Thank you!
How do I know Ctrl-V + Ctrl-I is ?
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
03-23-2008, 02:51 AM
Tim
sort with tab field separator
On Sat, 2008-03-22 at 23:49 +0000, Amadeus W.M. wrote:
> How do I know Ctrl-V + Ctrl-I is ?
You can look up the old ASCII charts for the control codes.
Hint: Read across both columns in the "man ascii" output.
--
(This computer runs FC7, my others run FC4, FC5 & FC6, in case that's
important to the thread.)
Don't send private replies to my address, the mailbox is ignored.
I read messages from the public lists.
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
03-23-2008, 11:37 AM
Sjoerd Mullender
sort with tab field separator
On 2008-03-23 00:06, Nicholas Robinson wrote:
On Saturday 22 March 2008 21:38:46 Nicholas Robinson wrote:
On Saturday 22 March 2008 21:18:11 Amadeus W.M. wrote:
You would think specifying tab as a field separator for sort would work
like this:
cat file | sort -k 3 -t " "
It doesn't:
sort: multi-character tab ` '
So after a little search and some trial and error I got this to work:
cat file | sort -k 3 -t "`/bin/echo -e ' '`"
For my own curiosity, can someone please illuminate me as to why the
first incantation does not work as expected? Is there a more natural way
to specify other than echo?
Take the double quotes out in your first attempt. So command becomes
cat file | sort -k 3 -t
Nick
Sorry, I was a little bit quick off the mark. The doesn't yield a tab
character (see below) as you were implying and I went along with in the first
example! If you take the double quotes out as I suggested, then the field
separator becomes the character t!
I think (being a little more cautious this time!) that you want:
followed by Ctrl V followed by Ctrl I
If I remember correctly, sort interprets a tab as a default field separator
anyway.
As to the why: it is because the -t takes an argument which is a character.
Putting double quotes around it stops the being elided and so as two
characters and t are presented to sort which is expecting only one
character. Hence its moan. Try echo " " and you will see what I mean.
In my second attempt above, the Ctrl V stops the tab character (Ctrl I) being
expanded on the command line and the joins the tab character to the t.
HTH
Nick
Easier:
sort -k 3 -t $' '
See `man bash' and look for $'string'.
--
Sjoerd Mullender
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
03-23-2008, 12:08 PM
Nicholas Robinson
sort with tab field separator
On Sunday 23 March 2008 12:37:29 Sjoerd Mullender wrote:
> On 2008-03-23 00:06, Nicholas Robinson wrote:
> > On Saturday 22 March 2008 21:38:46 Nicholas Robinson wrote:
> >> On Saturday 22 March 2008 21:18:11 Amadeus W.M. wrote:
> >>> You would think specifying tab as a field separator for sort would work
> >>> like this:
> >>>
> >>> cat file | sort -k 3 -t " "
> >>>
> >>> It doesn't:
> >>>
> >>> sort: multi-character tab ` '
> >>>
> >>>
> >>> So after a little search and some trial and error I got this to work:
> >>>
> >>> cat file | sort -k 3 -t "`/bin/echo -e ' '`"
> >>>
> >>>
> >>> For my own curiosity, can someone please illuminate me as to why the
> >>> first incantation does not work as expected? Is there a more natural
> >>> way to specify other than echo?
> >>
> >> Take the double quotes out in your first attempt. So command becomes
> >>
> >> cat file | sort -k 3 -t
> >>
> >> Nick
> >
> > Sorry, I was a little bit quick off the mark. The doesn't yield a tab
> > character (see below) as you were implying and I went along with in the
> > first example! If you take the double quotes out as I suggested, then the
> > field separator becomes the character t!
> >
> > I think (being a little more cautious this time!) that you want:
> >
> > followed by Ctrl V followed by Ctrl I
> >
> > If I remember correctly, sort interprets a tab as a default field
> > separator anyway.
> >
> > As to the why: it is because the -t takes an argument which is a
> > character. Putting double quotes around it stops the being elided and
> > so as two characters and t are presented to sort which is expecting
> > only one character. Hence its moan. Try echo " " and you will see what I
> > mean.
> >
> > In my second attempt above, the Ctrl V stops the tab character (Ctrl I)
> > being expanded on the command line and the joins the tab character to
> > the t.
> >
> > HTH
> >
> > Nick
>
> Easier:
> sort -k 3 -t $' '
>
> See `man bash' and look for $'string'.
>
Easier? More characters certainly!
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
03-23-2008, 12:40 PM
Aaron Konstam
sort with tab field separator
On Sun, 2008-03-23 at 14:21 +1030, Tim wrote:
> On Sat, 2008-03-22 at 23:49 +0000, Amadeus W.M. wrote:
> > How do I know Ctrl-V + Ctrl-I is ?
>
> You can look up the old ASCII charts for the control codes.
>
> Key sequence Hex Character / escape sequence / description
> ------------+-----+-------------------------
> CTRL+G 07 BEL ’a’ (bell)
> CTRL+H 08 BS ’’ (backspace)
> CTRL+I 09 HT ’ ’ (horizontal tab)
> CTRL+J 0A LF ’
’ (new line)
> CTRL+K 0B VT ’v’ (vertical tab)
> CTRL+L 0C FF ’f’ (form feed)
> CTRL+M 0D CR ’
’ (carriage ret)
>
> Hint: Read across both columns in the "man ascii" output.
>
> --
> (This computer runs FC7, my others run FC4, FC5 & FC6, in case that's
> important to the thread.)
>
> Don't send private replies to my address, the mailbox is ignored.
> I read messages from the pa characterublic lists.
>
That is only half of the answer. Ctrl-V forces the system to ignore the
action of the CTRL character that follows it and treat it as just
a character.
--
================================================== =====================
Take your work seriously but never take yourself seriously; and do not
take what happens either to yourself or your work seriously. -- Booth
Tarkington
================================================== =====================
Aaron Konstam telephone: (210) 656-0355 e-mail: akonstam@sbcglobal.net
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
03-23-2008, 05:00 PM
"Amadeus W.M."
sort with tab field separator
>>
> Easier:
> sort -k 3 -t $' '
>
> See `man bash' and look for $'string'.
>
> --
> Sjoerd Mullender
Good alternative, thanks!
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list