Search This Blog

2016-01-01

Add and Replce Lines Using Sed

Insert a line after the matched string

sed '/$match/ a "$new_line"' $filename


Insert a line before the matched string

sed '/$match/ i "$new_line"' $filename


Replace Matching Line

sed '/$match/ c "$replacement_line"' $filename


References:
http://arkit.co.in/linux/sed-command-20-practical-examples/
http://www.grymoire.com/Unix/Sed.html

No comments:

Post a Comment