LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-13-2004, 11:56 AM   #1
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
CLI copy & paste between text files?


I just got done reinstalling my system, and I want to copy over some of my old backed-up config file data to the new system. I don't want to simply replace the new with the old though; I only want to cut & paste parts of them.

So my question is, how can I C&P between two different files using a CLI text editor? I'm sure there's a simple way to do it, but I'm not sure how because you have to switch between running instances in the same shell. I usually use Joe for editing, but if another program is better for cut & paste, don't hesitate to recommend it.
 
Old 09-13-2004, 12:15 PM   #2
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 47
I get lazy and paste the whole file to the end and then cut it up..

do cat file1 >> file2

This copies the entire file1 and pastes it to the end of file2
The open the editor and move things about.
 
Old 09-13-2004, 12:26 PM   #3
MartinN
Member
 
Registered: Nov 2003
Location: Ronneby, Sweden
Posts: 555

Rep: Reputation: 30
emacs!

Quick tutorial for emacs beginners:

C-x means Control-x
M-x means Meta-x (which, on a PC keyboard is Alt-x)


To open a file: C-x C-f
To save a file: C-x C-s
To save as: C-x C-w
To get out of the minibuffer (for example, if you press C-x C-w and change your mind): C-g

To start marking text: C-space
To copy from mark to cursor: M-w
To cut from mark to cursor: C-w
To insert text: C-y

If you open a second file then you have two active buffers. To switch between active buffers: C-b
A tab here gives a list of possible buffers to switch between

To kill a buffer: C-k

Want more?
M-x help (that is 'M-x' and then type 'help' <RET>)
enters the help system.

Before leaving, make sure to try
M-x tetris
Use arrows and space to control and C-k to exit

To shut down emacs: C-x C-c


Enjoy the world of emacs!
Martin
 
Old 09-15-2004, 12:05 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Original Poster
Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
Thanks for the advice guys, especially the long tutorial. I suppose I should eventually learn how to use Emacs anyway, but I've heard it's kind of the kitchen sink of text editors. I'd much rather use something less bulky for most of my editing. Are there any lighter editors out there that have frame buffering also?

Also, how about Vim? Is there any feature in it that can handle such things? It's available almost everywhere.

Cat-ting the second file onto the first seems like the most convenient way to go about it generally, as long as the second file is a small one. I wouldn't want to cat a very long file like XF86config if I could at all help it, however.

Last edited by David the H.; 09-15-2004 at 12:06 PM.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
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 and paste between text editors sessions in bash pxes351 Linux - Newbie 2 05-06-2004 06:59 AM
Copy & Paste Dan Cerimele Linux - General 3 11-26-2003 05:49 PM
How to copy/paste text from boot, nongui Eradicator Linux - Newbie 2 10-31-2003 05:40 AM
Copy & Paste? petercool Linux - Software 9 09-03-2003 08:05 AM


All times are GMT -5. The time now is 06:41 PM.

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