help-gnu-utils
[Top][All Lists]
Advanced

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

Re: cut using -d """ -- can't pipe output. (textutils 2.1 under Win32.)


From: John Lowe
Subject: Re: cut using -d """ -- can't pipe output. (textutils 2.1 under Win32.)
Date: Tue, 11 Jan 2005 16:48:53 +0000
User-agent: Turnpike/6.04-M (<fPZoynJTKbII3tlBJDmz9VP1Jn>)

In message <41E3E0F6.40209@charter.net>, Mike Paulsen <mpaulsen@charter.net> writes
John Lowe wrote:
In message <41E38DED.7090503@charter.net>, Mike Paulsen <mpaulsen@charter.net> writes

Hello,

I'm having problems with cut (textutils 2.1 under Win32.)
http://unxutils.sourceforge.net/

I am unable to pipe or redirect the output when I specify the delimiter as a double quote (-d """).

cat temp.txt

2.0.0.127.blah blah blah "This is the text I want to end up with1"
2.0.0.127.blah blah blah "This is the text I want to end up with2"

cat temp.txt | cut -f2 -d """

This is the text I want to end up with1
This is the text I want to end up with2

cat temp.txt | cut -f2 -d """ | grep 1

cut: |: Invalid argument
cut: grep: No such file or directory
cut: 1: No such file or directory
You seem to be having problems with the difference between quoting in Windows and Unix. """ seems to be being taken as " so the rest of the line is quoted. I am not an expert, but I would try "\"" or "\042" or "\034" (I'm not sure whether the \digits would be taken as octal or decimal...). Someone who knows will be along in a moment.
 [snip further examples]

Thanks John,

I've tried single quotes, double quotes, and backslashes (and various combinations which would give you a good chuckle) without success. I either get the errors noted above or ones saying that the delimiter must be a single character. The only way I've found to specify double quote as the delimiter is """.

I'd like to learn what I'm doing wrong, but I'm not above using sed to replace the quotes with some other character if need be. This seems to work fine:

cat temp.txt
2.0.0.127.blah blah blah *This is the text I want to end up with1*
2.0.0.127.blah blah blah *This is the text I want to end up with2*

cat temp.txt | cut -s -f2 -d "*" | grep 1
This is the text I want to end up with1

So as long as * doesn't appear in your file you could try:

cat temp.txt | sed -e "s/""/*/g" | cut -s -f2 -d "*" | grep 1

or if that didn't work put s/"/*/g into a file called ased and:

cat temp.txt | sed -f ased | cut -s -f2 -d "*" | grep 1

or even, to remove the restriction put y/*"/"*/ into ased and:

cat temp.txt | sed -f ased | cut -s -f2 -d "*" | sed -f ased | grep 1

Sorry I couldn't produce a more elegant solution to the original problem!
--
John Lowe
jrnl@bytetype.co.uk

reply via email to

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