I’ve tried doing this myself with the following:
for i in $(grep something toprefix.log); do sed -i -e 's/^/prefix/' $i; done
First of all, apologies for the bone-headedness – I know the above doesn’t work!
Basically, I want to apply a prefix to matching lines in a log file using grep, and sed or awk.
prefix-matching
prefix-matching
not-matching
prefix-matching
not-matching
not-matching
prefix-matching
Thanks in advance.
Edit: For details see http://www.gnu.org/software/sed/manual/html_node/Addresses.html
Edit: Removed ‘<‘ since ‘-i’ is used.
Edit: Tabs are
\t, soadds
prefixand a tab.