I have a file which contains a like like this:
and a lot of extra lines which I'm not interested in. I need to transform this line into this:
and drop all other lines from the file. The MOD0 part is not predictable, so I need to match the line by the ^name= pattern. I can perform one substitution (remove the "name="), but how do I tell sed to perform another operation (surround the line with brackets), still on the same matched line? The following command surrounds every line with brackets:
sed -n -e '/^name=/ s/^name=//p; s/^.*$/\[&\]/p'