awk - copy a line with specific pattern and paste it below in unix without opening a file -


i have specific requirement.

i have file:

some text   . . . . .   . . . . .  **todo: owner comments . . . .**   ... .  sometext 

now want output like:

some text   . . . . .   . . . . .  **todo: owner comments . . . .**   **owner: todo comments . . . .**   ... .    .  sometext 

i want grep todo , copy line , paste below above modification. can possible without opening file... sed,awk command ??

thanks , regards, dharak

i guess mean opening file in editor. here awk script can tailor needs.

$ awk '/\*\*todo:/{print; print "**owner: todo ... ";next}1' file  text   . . . . .   . . . . .  **todo: owner comments . . . .**  **owner: todo ...   ... .  sometext 

you can save output temp file , move on original file.


Comments