LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-21-2007, 10:02 AM   #1
bhargav_crd
LQ Newbie
 
Registered: Sep 2007
Posts: 8

Rep: Reputation: 0
Smile 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......
 
Old 09-21-2007, 12:10 PM   #2
SeRGeiSarov
Member
 
Registered: Jan 2007
Location: Russia, Nizhniy Novgorod Region, Sarov town
Distribution: Mandriva 2007, Fedore Core 6
Posts: 52

Rep: Reputation: 15
Hi. May be this

Code:
sed '/pattern/a\Bugz:1033\a\\n\a\Bugz1039'
 
Old 09-24-2007, 06:56 AM   #3
bhargav_crd
LQ Newbie
 
Registered: Sep 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Thank You. I revisited 'sed' after long time, and got it. :-)

Last edited by bhargav_crd; 09-24-2007 at 06:57 AM.
 
  


Reply

Tags
sed


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plzz Help Me...! vishusudha Linux - Networking 1 08-08-2007 05:53 PM
help mee plzz XxHell-FirexX Linux - General 14 10-21-2005 09:53 PM
NTP help plzz Pranesh Solaris / OpenSolaris 3 06-30-2003 03:58 PM
ntp help plzz Pranesh Linux - Newbie 2 06-30-2003 03:56 PM
help plzz asap dejan_j Linux - Newbie 3 05-08-2003 09:11 AM


All times are GMT -5. The time now is 05:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration