Timeline for How to add parens around text
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 11, 2013 at 18:40 | vote | accept | Michael Durrant | ||
| Nov 10, 2013 at 21:21 | comment | added | Augusto Hack |
Added the docs about {}, so, yes, you can use it to group various commands for the same address (in your case the regular expression is the address, it could also be a line number or a range with a start and end separated by a ,), and the -i flag does not alter the script behavior, you can mix it with any sed script.
|
|
| Nov 10, 2013 at 21:18 | history | edited | Augusto Hack | CC BY-SA 3.0 |
added 315 characters in body
|
| Nov 10, 2013 at 21:15 | comment | added | Michael Durrant |
I like this approach. So as I read it, you basically 'qualify' the initial match and then use the "block" within the {} to do what you want? Can I do this sort of stuff with the sed -i same file approach?
|
|
| Nov 10, 2013 at 21:11 | comment | added | evilsoup |
-r may not be available in all versions of sed, in which case you'd have to escape the brackets on the left-hand side of the command. So POSIX-ly, this would be: sed -e 's/=~\(.*\)$/match(\1)/' file.
|
|
| Nov 10, 2013 at 21:03 | history | answered | Augusto Hack | CC BY-SA 3.0 |