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

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

Re: Maybe an issue with SED redirection or I missed something


From: Dan Witkowski
Subject: Re: Maybe an issue with SED redirection or I missed something
Date: Wed, 1 Jun 2011 00:15:36 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eli Zaretskii <eliz <at> gnu.org> writes:

> 
> > Date: Thu, 24 Mar 2011 10:44:12 -0600
> > From: "Rodney Fisher" <rodney.fisher <at> gov.ab.ca>
> > Cc: Rodney Fisher <rodney.fisher <at> gov.ab.ca>
> > 
> > I have tried a few tests with the SED command.
> > 
> > It seems to not handle the redirection arrows very well.....
> 
> It's not a Sed problem.  You are tripping the Windows shell by using
> unbalanced quotes.
> 
> > Y:\testsed>sed "s/\"//g" rf1 > rf2
> > Test sed to remove quotes.
> > Even if line like this has no quotes.
> > Or just has 1 quote like this line.
> > sed: can't read >: Invalid argument
> > sed: can't read rf2: No such file or directory
> 
> Because there are 3 quotes on the command line, cmd.exe gets confused
> and thinks that ">" is a file name.
> 
> You use a backslash to escape the second quote, but cmd.exe does not
> support such escapes.
> 
> In general, if you need to play with quotes on Windows, put your Sed
> command in a file and use "sed -f YOUR-FILE".
> 
> 

Others are right that it is the shell causing the issue, as I've run into the
same problem trying to strip double quotes from input using the sed utility for
Windows. The trick is to use the Windows escape (the ^ character) just before
the double quote and right after the regex escape (the \ character).

You are basically doing:

sed "s/\"//g" > out.txt

You should do:

sed "s/\^"//g" > out.txt

You have probably figured this out by now, but I wanted to include this answer
for anyone like myself who was searching for it.





reply via email to

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