[SOLVED] copy and paste text among text documents in Linux
Linux - NewbieThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.