LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Can U help me plzz.... (https://www.linuxquestions.org/questions/programming-9/can-u-help-me-plzz-586342/)

bhargav_crd 09-21-2007 10:02 AM

Can U help me plzz....
 
Hi all,

I'm new a member.
I'm doing on linux.
I want to write a linux shell script to insert 2 lines in middle of a file.

My requirement is
***Serch for a line, then insert 2 lines after that line***

Ex:
I hav a file called abc.
******FileName: abc******
Bug:1000
Bug:1010
Bug:1020
Bug:1030
Bug:1040
Bug:1050
**************************

I want to insert following lines
Bug:1033
Bug:1039

Final o/p should be as
******FileName: abc******
Bug:1000
Bug:1010
Bug:1020
Bug:1030
Bug:1033
Bug:1039

Bug:1040
Bug:1050
*************************

First i need to search for line "Bug:1030", then i need to insert 2 new lines after that.
Already i written a perl script to do same. but i need shell script also.

Thanks,
Bhargav......

SeRGeiSarov 09-21-2007 12:10 PM

Hi. May be this

Code:

sed '/pattern/a\Bugz:1033\a\\n\a\Bugz1039'

bhargav_crd 09-24-2007 06:56 AM

Thank You. I revisited 'sed' after long time, and got it. :-)


All times are GMT -5. The time now is 04:02 PM.