LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 10-11-2008, 04:33 PM   #1
fos
LQ Newbie
 
Registered: Jun 2008
Distribution: Ubuntu 10.04 LTS
Posts: 11

Rep: Reputation: 0
Copy text from the command line


Hello,
I often need to copy some text line from the command line in an text editor (emacs or nano). If I am using the terminal in a Gui, there aren't problems because i simply highlight the text and copy it, but how can I copy the text without using the mouse for example from a text only system ?

Thanks and sorry for my poor English, Francesco
 
Old 10-11-2008, 04:45 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
One possible alternative is to use "script"
Quote:
EXAMPLE:
% script test.txt
Script started, file is test.txt

% echo "Hello world!"
bash: !": event not found
<Ctl-D>
% Script done, file is test.txt

% ls -l test.txt
-rw-r--r-- 1 paulsm users 260 2008-10-11 14:44 test.txt

% cat test.txt
Script started on Sat 11 Oct 2008 02:43:54 PM PDT
% echo "Hello world!"
bash: !": event not found
%
Script done on Sat 11 Oct 2008 02:44:10 PM PDT

Last edited by paulsm4; 10-11-2008 at 04:46 PM.
 
Old 10-11-2008, 05:35 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Have a look at gpm.
 
Old 10-12-2008, 04:43 PM   #4
fos
LQ Newbie
 
Registered: Jun 2008
Distribution: Ubuntu 10.04 LTS
Posts: 11

Original Poster
Rep: Reputation: 0
I've tried the command script, it's really useful ! Thanks
About gpm can you tell me how to start using it ?

Thanks
 
Old 10-12-2008, 05:07 PM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by fos View Post
I've tried the command script, it's really useful ! Thanks
About gpm can you tell me how to start using it ?

Thanks
gpm is a daemon. It is loaded at startup. However, your distro might or might not be configured to run it by default. You will have to check your distro documentation to see how to add/remove services at startup. It really depends on the distro you use.

gpm enables the usage of the mouse in console, that way, you can select text like if you were on a terminal emulator. Then, to paste it, use the middle click button.


Yet another alternative is to use GNU screen, which besides the capability to do what you want, also adds lots of other interesting features. It's not a simple thing to learn, but it definitely worths the trouble.
 
Old 10-12-2008, 05:57 PM   #6
loperz7
Member
 
Registered: Sep 2008
Posts: 53

Rep: Reputation: 15
Or use a shell with the option to copy - like PowerShell or Gnome Terminal.

Gentoo

Last edited by loperz7; 10-23-2008 at 03:57 AM.
 
Old 10-12-2008, 06:40 PM   #7
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Manjaro
Posts: 963

Rep: Reputation: 36
try ctrl+insert to copy shift+insert to paste

thease are the origianal unix copy and paste shortcuts because of couse ctrl+c genrally aborts somthing...
 
Old 10-15-2008, 07:06 AM   #8
fos
LQ Newbie
 
Registered: Jun 2008
Distribution: Ubuntu 10.04 LTS
Posts: 11

Original Poster
Rep: Reputation: 0
Thank you everybody
I have learnt lots of things from your answers
Now i have resolved my problem with GPM, it is included in the repository of my distribution (Ubuntu).

Bye, Francesco
 
Old 10-15-2008, 07:27 AM   #9
AuroraCA
Member
 
Registered: Jul 2008
Location: Northern CA USA
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370

Rep: Reputation: 35
If you are using Ubuntu gpm is not loaded automatically.

Code:
sudo apt-get install gpm
That's it.
 
Old 10-15-2008, 01:55 PM   #10
evaluatinglinux
Member
 
Registered: Oct 2008
Posts: 45

Rep: Reputation: 15
Step 1
less <file_name> (this displays the content of the file on screen)
Step 2
copy paste the content using mouse (drag and select the text content you want)
Step 3
Shift+Insert into the window of your choice (this pastes the content you have copied in Step 1 into the window in focus)

Debian Kernel

Last edited by evaluatinglinux; 10-25-2008 at 02:51 AM.
 
Old 10-15-2008, 07:56 PM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The OP did specify "without using the mouse " ...
 
Old 10-16-2008, 06:13 AM   #12
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by chrism01 View Post
The OP did specify "without using the mouse " ...
Yep. But really, sometimes, "no" means "yes"

Jokes apart, by the tone of the first post, I understood that he was assuming that "text only system" implied "no mouse".

During the thread, several ways of achieving the desired purpose have been exposed and explained, and he already seem to have chosen the gpm based solution (mouse). The rest of solutions are valid of course. And each one can choose whatever fits him best.
 
Old 10-17-2008, 12:55 PM   #13
evaluatinglinux
Member
 
Registered: Oct 2008
Posts: 45

Rep: Reputation: 15
oopssie ... missed out the mouse part ... my bad!!!
 
Old 10-17-2008, 04:51 PM   #14
fos
LQ Newbie
 
Registered: Jun 2008
Distribution: Ubuntu 10.04 LTS
Posts: 11

Original Poster
Rep: Reputation: 0
In fact, at the beginning I'd copy the text, without using the mouse in a text only system.
But after, from the answers I hadn't found a directly solution to the problem, so I resolved that use GPM is a great alternative.
Anyhow if someone tell me how to select and copy text in a text only system without using the mouse (really ), I will be very thankful to him.
 
Old 10-19-2008, 05:59 AM   #15
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by fos View Post
In fact, at the beginning I'd copy the text, without using the mouse in a text only system.
I am a keyboard guy myself, but that statement comes from the assumption that mouse=graphics, which is not true.


Quote:
But after, from the answers I hadn't found a directly solution to the problem, so I resolved that use GPM is a great alternative.
Anyhow if someone tell me how to select and copy text in a text only system without using the mouse (really ), I will be very thankful to him.
Many valid alternatives have been declared in this thread. Mine is GNU screen, which has many many good features, besides copying text and pasting it. Google "GNU screen scrollback mode"

http://www.google.com/search?ie=UTF-...crollback+mode
 
  


Reply



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
How to copy-paste on command line? jameshao Linux - General 3 02-02-2009 01:14 AM
how to copy-past on command line? jameshao Linux - Newbie 5 02-01-2009 03:55 PM
Copy text from command line Duukkis Linux - General 8 08-25-2003 01:29 PM
copy a cd from the command line illtbagu Linux - General 32 02-09-2003 07:08 PM
Copy Paste under command line? Stingreen Linux - General 7 02-10-2002 06:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:33 AM.

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