The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
unable Insert data from .dat file to .xls can anybody help me kreddy2003 Shell Programming and Scripting 1 05-28-2008 05:33 AM
How to insert data into MYSql database from a text file shirleyeow Shell Programming and Scripting 4 01-11-2008 05:00 AM
How to insert new line in the data file using the script Sona UNIX for Dummies Questions & Answers 2 08-22-2006 01:17 AM
find the position in a file and insert the data there isingh786 HP-UX 5 04-11-2006 09:31 PM
how to insert data in database based on text file? forevercalz Shell Programming and Scripting 9 12-20-2005 11:40 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-03-2005
ctcuser ctcuser is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 39
Question sed, insert data from a file to another?

Hello,
I have 2 files. File1 has data I wrote, and File2 is a file created by an application. I would like to insert the data from File1 into File2, but it has to be inserted at a certain location on File2.

I know I need to search for
"</jsp-param>
</jsp-descriptor>"
But I don't know haw to insert data from File1 above the search criteria.

File1:
My Data.

File2:
<jsp-descriptor>
<jsp-param>
.....
-Insert into here
</jsp-param>
</jsp-descriptor>

Thanks in advance,
  #2 (permalink)  
Old 05-03-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
doing 'man sed' yields:
Quote:
Originally Posted by man sed
r rfile
Read the contents of rfile.
Place them on the output before
reading the next input line. If
rfile does not exist or cannot
be read, it is treated as if it
were an empty file, causing no
error condition.
  #3 (permalink)  
Old 05-03-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
You can easily solve this using vi editor using buffers.

Open file1 and file2 using vi editor
Code:
vi file1 file2
Copy the contents to buffer called "m" by

"m3yy ---- It will yank 3 lines to buffer called m


Navigate to file2 in vi editor by doing :e file2

navigate to the place in file2 where you want paste the contents in buffer m

and just do


"mp



There may be other methods by which you can achieve this easily.
  #4 (permalink)  
Old 05-03-2005
ctcuser ctcuser is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 39
Thanks Vgersh,
I looked at the man pages, and I still cannot figure out the RFile.
Can you please shed some light on this,

thanks,
  #5 (permalink)  
Old 05-03-2005
ctcuser ctcuser is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 39
Nevermind, figured it out.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0