Skip to main content

I have a file that I want to find a key word in and enter text 2 lines down.

For example lets say the file i have contains the following words

the cow goes moo

the
cow
goes
moo

I want to be able to find the word "cow" and enter the text "yay" into the file 2 lines below the word cow.

the cow goes moo yay

the
cow
goes
moo
yay

I believe this would be done with sedsed but cannot get it to work.

Any help is greatly appreciated.

I have a file that I want to find a key word in and enter text 2 lines down.

For example lets say the file i have contains the following words

the cow goes moo

I want to be able to find the word "cow" and enter the text "yay" into the file 2 lines below the word cow.

the cow goes moo yay

I believe this would be done with sed but cannot get it to work.

Any help is greatly appreciated.

I have a file that I want to find a key word in and enter text 2 lines down.

For example lets say the file i have contains the following words

the
cow
goes
moo

I want to be able to find the word "cow" and enter the text "yay" into the file 2 lines below the word cow.

the
cow
goes
moo
yay

I believe this would be done with sed but cannot get it to work.

Any help is greatly appreciated.

edited tags
Link
Source Link

How do I find a word in a file and insert text two lines below that?

I have a file that I want to find a key word in and enter text 2 lines down.

For example lets say the file i have contains the following words

the cow goes moo

I want to be able to find the word "cow" and enter the text "yay" into the file 2 lines below the word cow.

the cow goes moo yay

I believe this would be done with sed but cannot get it to work.

Any help is greatly appreciated.