4 ms·
You can use single quotes to escape everything except single quotes from the shell. Then use backslashes to escape single quotes where needed. If you haven't t
by userbinator 10y ago
You can use single quotes to escape everything except single quotes from the shell. Then use backslashes to escape single quotes where needed.
If you haven't taken the time, I'd say it's well worth learning exactly how the shell escapes work. It's surprisingly simple and natural once you get used to it.
- linkregister 10y agoThanks for the advice; I should block some time to fully grok shell escapes. Even with single quotes, sed still requires escaping parentheses, + operators, and other operators that would otherwise be interpreted literally (but not all operators should be escaped). In the languages that I learned regexes this wasn't required.
- NathanOsullivan 10y agoThere's a command line switch -E for sed that gives you what we think of as "normal" regex escaping.
- linkregister 10y agoYou have saved me many hours of future command line hacking. Thanks!