Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How to copy data in VI editor

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-11-07, 09:18
niranjan555 niranjan555 is offline
Registered User
 
Join Date: Aug 2007
Posts: 54
How to copy data in VI editor

Hi
I am new to shell scripting and vi editor.
I have 2 file and I want to copy some selected data from first file to other.

How can I do this ??


Thanks in advance


Regards
Reply With Quote
  #2 (permalink)  
Old 10-11-07, 10:09
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 830
Code:
vi first edit source file then move your cursor to start of selection 'ma mark current position with letter a then move your cursor to end of selection "xy'a yank to buffer x from current position to mark a :e other edit target file move cursor to where you want the data "xp put from buffer x
Reply With Quote
  #3 (permalink)  
Old 10-12-07, 01:30
niranjan555 niranjan555 is offline
Registered User
 
Join Date: Aug 2007
Posts: 54
Hi thnks for reply.

when i tried to give : 'ma

it show the mesage : E20: Mark not set.

but i used :r filename. It paste all the data from file2 to file1

After that I edited the file1. Problem solved.

But if the file2 is very big then it is not always possible to use :r method.

Pl reply how to use 'ma method..


Thanks and Regards
Reply With Quote
  #4 (permalink)  
Old 10-12-07, 05:28
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 830
Note:
NO : before 'ma
and I use :e not :r
Reply With Quote
  #5 (permalink)  
Old 10-12-07, 08:25
niranjan555 niranjan555 is offline
Registered User
 
Join Date: Aug 2007
Posts: 54
hi my file1 is like this:
PATH=......
SHELL=/bin/sh
USER=sa
LOGNAME=sybase
for i ........

then i use 'ma ( i think this is start of mark )
then my file will be (Vi in insert mode ):

PATH=......
'ma
SHELL=/bin/sh
USER=sa
LOGNAME=sybase
"xy'a
for i ........

is this code is right?? if it is,

Then i used :e file2

It gives the message as
E37: No write since last change ( add ! to override )

Pl reply


Thanks and regards
Reply With Quote
  #6 (permalink)  
Old 10-13-07, 04:07
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 830
No, don't insert it as text (don't modify file1)
You should not be in insert mode when entering the commands 'ma etc.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On