|
From: | Manuel Collado |
Subject: | Re: sed ssed bug with the windows binaries |
Date: | Sat, 14 Nov 2009 12:43:28 +0100 |
User-agent: | Thunderbird 2.0.0.19 (Windows/20081209) |
Eli Zaretskii escribió:
Date: Fri, 13 Nov 2009 10:46:22 +0100 From: Guillaume Frambourg <address@hidden> Working sed is : -------------------------------------------------------- sed -e "s/\"//g" test.txt -------------------------------------------------------- it outputs : -------------------------------------------------------- hello -------------------------------------------------------- But if you try : -------------------------------------------------------- sed -e "s/\"//g" test.txt > test2.txt -------------------------------------------------------- it outputs : -------------------------------------------------------- hello sed: can't read >: Invalid argumentThat's not a problem with Sed, this is a problem with the Windows shell's too naive handling of quotes. The Windows shell doesn't understand the backslash escape, so it thinks the second quote closes the first one, and the 3rd one quotes everything up to the end of the command.
The DJGPP port of set works OK, because it parse the command line itself. But both the Cygwin and the MinGW ports emit the given error message.
The escape character of the Windows shell is `^'. However, it doesn't escape inside quoted strings :-(. So you need to get creative. For example: sed -e "s/"^""//g" test.txt > test2.txt This quotes parts of the Sed expression separately, with the literal quote escaped by `^'.
This does not work for me. It seems that quotes in the command line must always be in pairs. I.e. there must be an even number of quotes in each argument. The workaround is to use the octal escape code for the quote character:
sed -e "s/\042//g" test.txt > test2.txt Hope this helps. -- Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
[Prev in Thread] | Current Thread | [Next in Thread] |