|
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>) |
John Lowe wrote:In message <41E38DED.7090503@charter.net>, Mike Paulsen <mpaulsen@charter.net> writesYou 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.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.txt2.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 with2cat temp.txt | cut -f2 -d """ | grep 1cut: |: Invalid argument cut: grep: No such file or directory cut: 1: No such file or directory[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.txt2.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 1This 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 1Sorry I couldn't produce a more elegant solution to the original problem!
-- John Lowe jrnl@bytetype.co.uk
[Prev in Thread] | Current Thread | [Next in Thread] |