LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 12:56 PM   #1
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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, 01:15 PM   #2
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
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, 01: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, 01:05 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Original Poster
Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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 01: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 12:28 PM
how to copy and paste between text editors sessions in bash pxes351 Linux - Newbie 2 05-06-2004 07:59 AM
Copy & Paste Dan Cerimele Linux - General 3 11-26-2003 06:49 PM
How to copy/paste text from boot, nongui Eradicator Linux - Newbie 2 10-31-2003 06:40 AM
Copy & Paste? petercool Linux - Software 9 09-03-2003 09:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:57 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration