4 ms·
Is there a command to automatically escape a string for use in sed? I got frusturated escaping for simple replacement: https://github.com/jakeogh/replace-text
by jakeogh 12y ago
Is there a command to automatically escape a string for use in sed?
I got frusturated escaping for simple replacement: https://github.com/jakeogh/replace-text https://github.com/jakeogh/replace-text
- klshxsh 12y agoIf you find yourself having to escape a lot of slashes, then you can do something like this: echo "/foo/bar" | sed -e 's|/foo|/tmp|' (The article mentions this)
- JetSpiegel 12y agoIt can be any character really. I like sed 's,foo,bar,' sed 's@foo@bar@'
- Tobu 12y agoPython has re.escape; awk can take variable definitions from the command line: echo b |awk '/b/{print a}' a=4