[Top][All Lists]

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

bug#7007: cannot pipe or redirect output from cut

From: David Longstaff
Subject: bug#7007: cannot pipe or redirect output from cut
Date: Fri, 10 Sep 2010 19:44:39 +0100

Hi Eric,

I understand that I need to use cmd's quoting rules, or in this case
escaping rules. I thought that the backslash char (\) was the escape
character in cmd, as I say I am a Unix guy more than a windows guy. I have
since found out that the backslash char (\) does not escape a double quote
char (") except when used to escape a double quote char (") that is
surrounded by a pair of double quotes chars, in a syntactically valid use
(e.g. "<some chars>\"<some more chars>"). This is why it worked in the
findstr invocation in my pipeline (findstr "name=\"Name\""). I guess I
should have realised as the backslash char (\) is the file system element
separator. It seems the cmd escape character is normally the caret character
(^) except for a double quote char ("), in such case using three double
quote chars (""") is working for me (I am using Vista for all this, sorry
forgot to mention). Thus the following works and I am now happy:-

C:\Users\drl.drlpc>cat "Table of Contents.txt"|findstr "name=\"Name\""|cut
-d """ -f 4

I know ksh is the normal abbreviation for the Korn shell, however it
normally refers to those pre the 93 Korn shell, still the most commonly
bundled version, in my experience. The 93 Korn shell is generally referred
to as the "New Korn shell", and I used that to be explicit to which version
I was referring to.

I have actually used the Cygwin port of ksh, on a customer's site, the
problem is not all customer's will permit it to be installed, I confess I do
not understand why, so I stick to Perl for scripting, as I have yet to find
anybody object to it being installed. Also, I did find not all my ksh
scripts ran unaltered, so again I prefer Perl. For those quick "one off's
now that I have a better handle on cmd quoting/escaping, and have the
Core-utils I am content for the moment, until the next problem. ;)

My apologies for not sending my replies to the list, rather than to
individual developers, I was merely replying to your kind response and
clicked "Reply" out of habit instead of "Reply to all". My habit used to be
to click "Reply to all", but it once got me into trouble when I didn't
notice an addressee who should not have seen the confidential reply.

I would like to thank you for your patience and kind assistance with this
matter, especially as the problem was not with "cut", but my use of cmd,
and, of course, I consider this report answered and closed. In fact I thank
you for accepting it, as the problem was not with "cut".

Kind Regards

-----Original Message-----
From: Eric Blake [mailto:address@hidden 
Sent: 10 September 2010 18:38
To: David Longstaff
Subject: Re: bug#7007: cannot pipe or redirect output from cut

On 09/10/2010 11:26 AM, David Longstaff wrote:
> Hi Eric,
> Thanks for your prompt and sound reply.
> Sorry I didn't let you know it was cmd, I thought the coreutils where for
> use with cmd didn't realise I needed a unix-y shell as well.

Yes, the coreutils can be used from cmd - they are regular Windows 
programs, and can be invoked just like any other program.  It's just 
that you have to then learn cmd's quoting rules, which are rather different.

> This, of
> course, is the danger of making assumptions. To be honest I have never
> that happy with unix-y shells on windows even though I am a Unix guy and
> preference is the New Korn shell.

Cygwin includes a port of ksh (is that not what you meant by the New 
Korn shell?).

> What I really need is to be able to escape the double quote (")
> character, in cmd. I thought \ would do that but it doesn't, as you
> point out.

I detest cmd, so I can't help you other than to suggest trying "\"", 
since \" doesn't seem to work in isolation.

Remember, the bug is NOT in the port of cut, but in your usage of cmd to 
pass arguments to cut in the first place.

And in general, it is a better idea to send mail to the list, rather 
than to individual developers, so that others may benefit from reading 
the archives of what you have learned.

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

reply via email to

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