Sed Append Text Before After Sample
업데이트:
In this page, I will show you some examples about Linux sed command which append some text (before/after) matching text.
Assumption & Background
- Your OS is CentOS 6.5
Append Text Before Matching Text
# The following sed command will paste "Some More Text is appended" after matching text "Please Put it here"
sed -i'' -r -e "/Please Put it here/i\Some More Text is appended/" your_file.txt
Append Text After Matching Text
# The following sed command will paste "Some More Text is appended" after matching text "Please Put it here"
sed -i'' -r -e "/Please Put it here/a\Some More Text is appended/" your_file.txt
- Those who are interested in basic sed, click this