|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Insert text file at a certain line.
I need to insert a file called temp_impact (which has about 15 lines in it) to a file called 11.23cfg starting at line 33. I searched the forums and found the
sed '34i\ test' 11.23cfg > newfile That will enter word test at the appropriate line, but i need the entire file dumped there. Any help would be appreciated. This is on an HP system so no bash shell is avalible, just sh. Is there anyway to do this with sed or is there a better way to insert it all together. Sean |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
open the file you want to move things into with vi. Move the cursor down to line 15 Press colon r filename eg.: Code:
:r filename.txt Press return. The lines from filename.txt will be read and inserted in between the old lines 15 & 16 of the file you first opened with vi |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I am sorry I forgot to add this is suppose to be automated in a script, is there a way to open vi and have it insert with that command at line 35 and close with no user intervention?
|
|
#4
|
|||
|
|||
|
I wrote a script which does just that:
http://comp.eonworks.com/scripts/insertext |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Try something like this: Code:
sed '33r temp_impact' <11.23cfg >11.23cfg.tmp mv 11.23cfg.tmp 11.23cfg Jean-Pierre. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using sed to insert text file at first line | psve | Shell Programming and Scripting | 18 | 03-29-2011 03:44 AM |
| Sed insert text at first line of empty file | DC Slick | Shell Programming and Scripting | 4 | 02-18-2011 02:17 AM |
| How to insert some constant text at beginig of each line within a text file. | Muhammad Afzal | Shell Programming and Scripting | 4 | 10-30-2008 11:01 PM |
| Insert a line in a text file | 4scriptmoni | Shell Programming and Scripting | 10 | 08-04-2008 10:17 AM |
| how to insert a extra line in a text file | bhaviknp | Shell Programming and Scripting | 2 | 03-07-2008 07:38 AM |
|
|