Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • -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. Commented Nov 10, 2013 at 21:11
  • 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? Commented Nov 10, 2013 at 21:15
  • 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. Commented Nov 10, 2013 at 21:21