I am trying to build a Linux command to find a line in file and add more lines below that line. For example search for "Application" in a file, then get the line where this word is and add three more lines below it.
I am currently using the absolute line number as in "sed -i '51icolumn1, column2, column3' test.txt" but if something change in this file I might be adding the text in a wrong place.
Add a comment
|
1 Answer
Would
sed -i '/Application/a column1, column2, column3\ncolumn1, column2, column3' test.txt
solve your issue?
2 Comments
Juampa
My problem is when I try to add more than one line after search for the word "Application"
Micha Wiedenmann
Have you tried to use '\n' to separate multiple lines? (I updated my answer.)