0

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.

1 Answer 1

2

Would

sed -i '/Application/a column1, column2, column3\ncolumn1, column2, column3' test.txt

solve your issue?

Sign up to request clarification or add additional context in comments.

2 Comments

My problem is when I try to add more than one line after search for the word "Application"
Have you tried to use '\n' to separate multiple lines? (I updated my answer.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.