Powered by Invision Power Board


  Reply to this topicStart new topicStart Poll

> Sed : how to replace a paragraph with a file
yahoofan
Posted: May 17 2005, 11:28 PM
Quote Post


Newbie
*

Group: Members
Posts: 3
Member No.: 1007
Joined: 17-May 05



Please help. Thanks!

Problem
file a:

starta
stop1a
stop2a
enda

file b:
start b
end b

now I want to replace /stop1a/,/stop2a/ with file b. Note that you are NOT allowed to search starta and enda

how to do it and do it beautifully Thanks!!
PMEmail Poster
Top
yahoofan
Posted: May 18 2005, 05:10 PM
Quote Post


Newbie
*

Group: Members
Posts: 3
Member No.: 1007
Joined: 17-May 05



anyone? any suggestion/comment?
PMEmail Poster
Top
andyb1ack
Posted: May 20 2005, 09:41 AM
Quote Post


User Level: 4
****

Group: Members
Posts: 98
Member No.: 513
Joined: 9-September 04



There may be a way of doing this in one go that I don't know of, but this is quite simple to follow:

CODE

$ cat /var/tmp/file1
starta
stop1a
stop2a
enda

$ cat /var/tmp/file2
start b
end b

$ cat /var/tmp/asb.ksh
sed -n '1,/stop1a/p' /var/tmp/file1 |grep -v stop1a
cat /var/tmp/file2
sed -n '/stop2a/,$p' /var/tmp/file1 |grep -v stop2a

$ ksh /var/tmp/asb.ksh
starta
start b
end b
enda
PMEmail Poster
Top
yahoofan
Posted: May 20 2005, 05:43 PM
Quote Post


Newbie
*

Group: Members
Posts: 3
Member No.: 1007
Joined: 17-May 05



Good thinking, Thanks.
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Shells & Scripting | Next Newest »

Topic Options Reply to this topicStart new topicStart Poll

 



[ Script Execution time: 0.1366 ]   [ 12 queries used ]   [ GZIP Enabled ]




Partners: Cambridge Plus :: <Link Available> :: PCB Layout, CadStar :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum