[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: |
Eric Blake |
Subject: |
bug#7007: cannot pipe or redirect output from cut |
Date: |
Fri, 10 Sep 2010 08:01:47 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2 |
[please keep the list and bug-tracker in the loop]
On 09/10/2010 06:07 AM, David Longstaff wrote:
I have since determined that the problem is using the double quote character
(") as the delimiter:
This works:-
****************************************************************************
*******
C:\Users\drl.drlpc>cat "Table of Contents.txt"|findstr "name=\"Name\""|cut
-d = -f 3>> strippedcontents.txt
Aha! Your problem is that you are using cmd as your shell, which has
completely different quoting rules than Unix-y shells. It would have
been helpful if you had told us you were using a Windows port in the
first place.
****************************************************************************
********
This doesn't:-
****************************************************************************
********
C:\Users\drl.drlpc>cat "Table of Contents.txt"|findstr "name=\"Name\""|cut
-d " -f 3>> strippedcontents.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.
Makes sense - the " is a quoting character in cmd, which meant the
entire rest of your command line was passed as a single argument to cut;
but cut correctly told you that a multi-character argument is
inappropriate for -d. It doesn't help that cmd apparently tries to be
helpful by letting you use quoted strings without at terminating ".
****************************************************************************
********
Nor does this:-
****************************************************************************
********
C:\Users\drl.drlpc>cat "Table of Contents.txt"|findstr "name=\"Name\""|cut
-d '"' -f 3>> strippedcontents.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.
cmd doesn't use '' for quoting, just " and \.
****************************************************************************
********
Nor this:-
****************************************************************************
********
C:\Users\drl.drlpc>cat "Table of Contents.txt"|findstr "name=\"Name\""|cut
-d \" -f 3>> strippedcontents.txt
cut:>>: Invalid argument
cmd apparently also fails to treat >> as an append operator, and instead
treats it as an argument.
It seems to me that your real problem is that you are using the wrong
shell for your expectations. Have you considered using cygwin (see
cygwin.com), which comes with bash or tcsh pre-built for Windows, and
where you can blindly use Unix shell conventions without having to worry
about the brain-dead semantics of cmd?
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org