- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Inserting text into a file after a particular ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2001 01:14 PM
тАО06-18-2001 01:14 PM
I got some problem I have a file(Eg File1) which contains some text and after 12th line I want to insert one line from another file(Eg File2) can any body help me out how to write a script so as to satisify my cause
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2001 02:01 PM
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2001 09:57 PM
тАО06-18-2001 09:57 PM
Re: Inserting text into a file after a particular line reading form another file
open both files using vi (vi file1 file2)
in file1 at 12th line press 'o' which creates a blank line. switch over to file2(esc, :!2)
yank the line you wanted from file2 , again switch to file1 and put in blank line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2001 07:21 AM
тАО06-19-2001 07:21 AM
Re: Inserting text into a file after a particular line reading form another file
awk '{if(NR<12){print}}' file2 > tmpfile
somehow print the one line >> tmpfile
awk '{if(NR>11){print}}' file2 >> tmpfile
cp tmpfile file2 ; rm tmpfile
The first line prints the first 11 lines of file 2. The second line, supplied by you, adds in the line from the other source. The third line adds the remainder of file 2. Line 4 replaces file 2 with the new version.
Note this could be made more efficient, if you have a very large file2. Awk could be told to exit when it has nothing else to do, rather than have it go through all the lines in the file regardless.
Fred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2001 06:20 AM
тАО06-20-2001 06:20 AM
Re: Inserting text into a file after a particular line reading form another file
head -12 file1;cat file2;tail +13 file1
Robin