Unix Tip #4427- April 25, 2023


SEARCH : Home : Help : Today's Tip

VI COPING BETWEEN FILES


VI editor is a very powerful editor.
Suppose you want to copy
line numbers 1-10 and 23-77 of
file A and paste them on file B at
the same time, what will
you do ?? Here I am giving a tip
to do this :-

Place the cursor on line no. 1
Press ESCAPE
Press Shift "(Shift double quotes)
Press a
Press 10yy [the number of lines you
want to copy]

Now place the cursor on line no. 23
Press ESCAPE
Press Shift "(Shift double quotes)
Press b
Press 55yy [the number of lines you
want to copy]

Now the first 10 lines have been
copied in buffer "a" and next
55 lines have been copied in
buffer "b".

Now press " : " (COLON) to get
the vi prompt.
Hit e "Destination file name"

Once you enter the Destination file
go to the line where you
want the first 10 lines in buffer
"a" to be inserted.

Press ESCAPE.
Press Shift "(Shift double quotes)
Press a.
Press p.

The first 10 lines in buffer "a"
gets inserted.

Now go to the line where you want the
rest 55 lines in buffer
"b" to be inserted.

Press ESCAPE.
Press Shift "(Shift double quotes)
Press b.
Press p.

The rest 55 lines in buffer "b"
gets inserted.


This tip generously supported by: ardhendu99@yahoo.com

NOTE: All tips provided are USE AT YOUR OWN RISK. Tips are submitted by various unix admins around the globe. UGU suggest you read and test each tip in a non-volitile environment before placing into production.


LAST 5 TIPS
4426 - KILL REALLY DOES NOT KILL
4425 - XVI A FILE
4424 - CAT A BINARY FILE, OOPS!
4423 - WHERE WAS IT STARTED?
4422 - TRIMMING THE LOG


I want to SUBSCRIBE and get a UGU Tip everyday.
I want to UNSUBSCRIBE and NOT get a UGU Tip everyday.

If you have a UNIX TIP let us know, we just may use it:
(All tips become the property of the Unix Guru Universe)
Email Address:

Yes, email me a Hot Unix Tip everday.

Enter Hot Unix Tip (optional):

Yes, I will support this tip

Captcha (not case sensitive):


Please enter the above letters:


HOME | Flavors | Admin | Network | Security | S/W | Help | Events | Vendors | Careers | Internet
About | Add Link | Feedback | Search

Copyright © 1994-2005 Unix Guru Universe