strange SED question
Composing this question, I somehow think of David Letterman and the "Stupid Pet Tricks"......
Helping someone on SED, I came up with a puzzle: This works: sed 's\old\new\g' filename replaces old with new with "\" acting as the delimiter. Now, how would one "escape" something inside the expression? |
A quick google search shows instances of double backslash to escape a character, as well as a few instances in which quadruple backslash is used.
|
Can't say, since it depends which sed you're using. According to the standard, backslash is illegal as a delimiter in an s expression.
|
Quote:
Just adding more backslashes won't do it, because "s" simply goes from one to the next---eg: sed 's\\\' means "replace the first occurrence of nothing with nothing |
I'd use the square brackets to match a string made of a single character. For example suppose you have a file containing a <tab>
Code:
>>> cat testfile Code:
>>> cat testfile |
pixellany, go take your medications and lie down .... ;)
No-one (I mean no sane person) would do that. |
Quote:
Seriously, you are of course right. But I (we) did learn something: BASH doesn't follow the standards + the post by colucix (Thank you) I will go back to using my mother's maiden name for the delimiter..... |
Quote:
Cheers, Tink |
Quote:
Ciao :] |
All times are GMT -5. The time now is 08:15 AM. |