Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-28-2010, 12:41 AM
|
#1
|
|
Member
Registered: Jan 2010
Distribution: slackware 13.0 64
Posts: 259
Rep:
|
copy and paste text among text documents in Linux
Dear all,
what is the best way to copy and past some text among text documents in Linux terminal environment? Suppose I have 2 documents, A and B, and I want to copy some part of A to B. What is the way to achieve this?
Regards,
ethereal1m
Last edited by ethereal1m; 03-28-2010 at 01:25 AM.
|
|
|
|
03-28-2010, 01:06 AM
|
#2
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,357
|
You mean virtual terminals (accessed by Ctrl+Alt+F<n>) or terminal emulators running in pseudo terminals (xterm and similar) under X?
What sort of documents? Plain text or special format such as .pdf, .odt ... ?
You want to copy interactively or programmatically?
|
|
|
|
03-28-2010, 01:34 AM
|
#3
|
|
Member
Registered: Jan 2010
Distribution: slackware 13.0 64
Posts: 259
Original Poster
Rep:
|
Hmm, I guess there are some differences between doing it in terminal emulator and virtual terminal. I want to do copy and paste of plain text files in virtual terminal, terminal emulator, and any Linux command line shell.
Can I use vi editor to do that? Can I do this in Linux command shell: copy some part of A using vi editor, suspend vi for A, open B with another vi editor and paste the copy to the document? Do I need some sort of clipboard in between copy and paste? I'm not familiar with linux clipboard though.
|
|
|
|
03-28-2010, 02:10 AM
|
#4
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,357
|
Quote:
Originally Posted by ethereal1m
Hmm, I guess there are some differences between doing it in terminal emulator and virtual terminal. I want to do copy and paste of plain text files in virtual terminal, terminal emulator, and any Linux command line shell.
Can I use vi editor to do that? Can I do this in Linux command shell: copy some part of A using vi editor, suspend vi for A, open B with another vi editor and paste the copy to the document? Do I need some sort of clipboard in between copy and paste? I'm not familiar with linux clipboard though.
|
AFAIK any command line shell that you can interact with is going to be running in a terminal so "and any Linux command line shell" doesn't add anything to the requirement.
vi or vim would be a good way to do it. Use command "vi file1 file2" to open both files in vi or vim and then use ...
:n and :e# to switch between files
Buffers to copy and paste. For example "a5yy (including the ") would name buffer a, do 5 times of yanking a line then, where you want to paste the 5 lines, "ap to name buffer a and put its contents after the current line.
Alternatively you may be able to mark text using Shift+left-mouse-drag followed by Shift+Ctrl+C to copy then paste it where you want by going to the place and starting insert mode then pasting by Shift+Ctrl+V. This works for me but the Shift+Ctrl+C and Shift+Ctrl+V maye be part of the terminal emulator and may not work for you.
X copy and paste works by selecting (that's all!) to copy followed by middle mouse button to paste. On mice without a middle button scroll-wheel click or pressing left and right buttons simultaneously can be used to emulate pressing the middle button.
Last edited by catkin; 03-28-2010 at 02:11 AM.
|
|
|
|
03-28-2010, 02:12 AM
|
#5
|
|
Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 6,324
|
The short answer would be to a use vim and then use that command with -o option which allows you to have multiple
files opened all at once: ie vim -o A.txt B.txt
The reason for asking where you are doing the work, virtual or pseudo, is because in the X environment you can use
your mouse to highlight and paste.
Also, there are several other tools, sed - awk - perl (to name a few), which allow you to manipulate text and add/subtract/change
text in files.
|
|
|
|
03-28-2010, 03:14 AM
|
#6
|
|
Member
Registered: Jan 2010
Distribution: slackware 13.0 64
Posts: 259
Original Poster
Rep:
|
hi all, thanks 
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:51 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|