Re: errors in sed manual 4.2.2
Davide Brini <[email protected]>
| Newsgroups | gmane.comp.gnu.utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 9 Aug 2014 15:15:51 +0100, bamber ward <[email protected]> wrote: > I have tried to construct examples to test out \`(backslash backtick) but > have not succeeded in getting the responses I want. I assume that > backtick is the same as backquote. Backticks as in `command`. > for instance, > echo cat | sed "s/\`cat/bingo/" > gives cat You're hitting shell escaping issues. If you're in doubt, a way to check is putting the sed program in a file, then running with sed -f prog.sed. In this first example, sed sees: s/`cat/bingo/ as your shell is most likely removing the backslash before the backtick. So the result is correct: no replacement is made, as the input does not contain `cat Instead, you probably want one of these: $ echo cat | sed 's/\`cat/bingo/' bingo $ echo cat | sed "s/\\\`cat/bingo/" > echo cat | sed "s/\`cat\'/bingo" # double quotes because of single quote > gives cat As written, that gives an error: sed: -e expression #1, char 14: unterminated `s' command If, as I think, you meant instead echo cat | sed "s/\`cat\'/bingo/" then again the shell removes the first backslash and sed sees s/`cat\'/bingo/ and the result is again correct, no replacement as the input does not contain `cat Working alternatives: $ echo cat | sed "s/\\\`cat\'/bingo/" bingo $ echo cat | sed 's/\`cat'\\\''/bingo/' bingo > but > echo cat | sed "s/cat\'/=/" gives > = Here sed sees s/cat\'/=/ so there is a match and the replacement is performed. Note that \` and \' are GNU sed specific extensions and will not work on other sed implementations. On a related note, it's quite difficult to find the download link for the latest source, as this page is outdated: http://directory.fsf.org/wiki/Sed and here http://www.gnu.org/software/sed/sed.html there's no download link, nor do the docs (http://www.gnu.org/software/sed/manual/) say where it can be downloaded. And finally, http://www.gnu.org/software/sed/manual/sed.html seems still to be for 4.2.1. -- D.