LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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

Reply
 
Search this Thread
Old 03-28-2010, 12:41 AM   #1
ethereal1m
Member
 
Registered: Jan 2010
Distribution: slackware 13.0 64
Posts: 259

Rep: Reputation: 30
Question 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.
 
Old 03-28-2010, 01:06 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
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?
 
Old 03-28-2010, 01:34 AM   #3
ethereal1m
Member
 
Registered: Jan 2010
Distribution: slackware 13.0 64
Posts: 259

Original Poster
Rep: Reputation: 30
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.
 
Old 03-28-2010, 02:10 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by ethereal1m View Post
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.
 
Old 03-28-2010, 02:12 AM   #5
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,517

Rep: Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896Reputation: 1896
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.
 
Old 03-28-2010, 03:14 AM   #6
ethereal1m
Member
 
Registered: Jan 2010
Distribution: slackware 13.0 64
Posts: 259

Original Poster
Rep: Reputation: 30
hi all, thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inquiry:How to Copy/Paste in vi text editor ? hadimotamedi Linux - Newbie 7 09-19-2009 05:28 AM
Inquiry:How to copy/paste in vi text editor hadimotamedi Linux - Newbie 7 08-31-2009 06:58 PM
Copy Text File and Paste to /hdd CD-RW aquatux Suse/Novell 3 12-29-2006 06:32 AM
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 11:28 AM
How to copy/paste text from boot, nongui Eradicator Linux - Newbie 2 10-31-2003 05:40 AM


All times are GMT -5. The time now is 11:43 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration