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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Removing specific lines catgovind Shell Programming and Scripting 3 04-30-2008 05:40 AM
Inserting Lines between data sets using SED? selkirk Shell Programming and Scripting 1 09-25-2007 02:24 AM
How to print specific lines with awk Bugenhagen Shell Programming and Scripting 10 08-16-2007 06:41 AM
Printing lines with specific awk NF jehrome_rando Shell Programming and Scripting 1 03-13-2007 04:23 AM
viewing specific lines dakid UNIX for Dummies Questions & Answers 3 05-25-2006 03:25 AM

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 04-29-2002
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
Inserting specific lines in vi

How can I insert, say lines 500 - 700 from another file into the current file on the current line (cursor) that I am editing while in vi (AIX).

I know how to insert the entire file but how do you do it when you only need certain lines from a huge file?

I've referenced my Unix Unleash book but it doesn't say...

Thanx
  #2 (permalink)  
Old 04-29-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Try:
:r !sed -n '500,700p' < anotherfile

But I rarely happen to know that I need exactly those lines. What I do is first "vi insert", read in the other file, delete what I don't want, then edit the real file and read in insert.
  #3 (permalink)  
Old 05-01-2002
J.P's Avatar
J.P J.P is offline
Registered User
  
 

Join Date: Nov 2001
Location: Sweden
Posts: 67
here's another solution, but you'll need a vi-clone that
supports multiple 'windows' (e.g Vim, Elvis etc..):

$ vi currentfile

:split anotherfile

highlight lines 500 - 700
500G
V
700G
d

Insert lines in current file
Move down to the other file (^wj) and press:
p



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 10:50 PM.


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