LinuxQuestions.org
Help answer threads with 0 replies.
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 04-05-2010, 11:58 AM   #1
anth0ny5
LQ Newbie
 
Registered: Mar 2010
Posts: 25

Rep: Reputation: 0
Copy to 'clipboard' from shell


Seems a utility called "xclip" and "xsel" are required, but is there anything simpler, that doesn't require extra utilities, along the lines of
Code:
cat foo.txt > clipboard
This would for GNOME.
 
Old 04-05-2010, 12:25 PM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Take a look at gpm which allows you to copy and paste with your mouse whilst you are in a true terminal shell ( the "boring", non-GUI type ).
 
Old 04-05-2010, 01:24 PM   #3
anth0ny5
LQ Newbie
 
Registered: Mar 2010
Posts: 25

Original Poster
Rep: Reputation: 0
Quote:
Gpm provides mouse support to text-based Linux applications like the Emacs editor and the Midnight Commander file management system. Gpm also provides console cut-and-paste operations using the mouse and includes a program to allow pop-up menus to appear at the click of a mouse button.
I'm okay with using the mouse to copy-paste from a terminal, but because the terminal might interpret characters differently I wanted to by-pass it completely, sort of like redirecting output to the clipboard. I guess there's no easy way to do this, otherwise google would have found something by now...
 
Old 04-05-2010, 01:44 PM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Because you have not really explained your situation (what you'd like to be able to do, with what processes / commands ), I think I do not really understand your question.

If you are in a terminal, you can redirect "output" from one process to the "input" of another with the pipe "|" symbol. Eg
mount | grep sda

For all the gory details of redirection and piping, please see man bash
 
Old 04-05-2010, 01:52 PM   #5
anth0ny5
LQ Newbie
 
Registered: Mar 2010
Posts: 25

Original Poster
Rep: Reputation: 0
I'm familiar with redirection, the example I give in my first post is pretty straight-forward: I'm wondering if there is some series of shell commands that will allow me to easily redirect output to the clipboard.
i.e. say I have some text "bar" in file "foo.txt". Currently inorder to get these contents into the copy buffer I need to do something like "cat foo.txt" then copy-paste the console output. This is both tedious and prone to error as I discovered with certain non-ASCII data. So what I'd like to be able to do instead is directly insert something into the copy-buffer. The only solution I've found to do this is xclip, so I'm wondering if there are any, more native, alternatives.

Last edited by anth0ny5; 04-05-2010 at 01:54 PM.
 
Old 04-05-2010, 03:26 PM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
I'm wondering if there is some series of shell commands that will allow me to easily redirect output to the clipboard.
Which "clipboard" ?

AFAIK "the shell" has no concept of "clipboard". There may be "copy buffers" in applications like vi and emacs, but I don't think this is what you are looking for. Otherwise, gpm is pretty good.

"Clipboards" are a GUI concept. How they handle them depends on the GUI you are running, but you are asking for shell commands.
 
Old 04-05-2010, 03:37 PM   #7
anth0ny5
LQ Newbie
 
Registered: Mar 2010
Posts: 25

Original Poster
Rep: Reputation: 0
Yep, that makes sense, but like you can control the GUI via the shell (i.e. startx, system-config-display, etc.), was wondering if there was such a command to control GNOME's 'clipboard'.
 
Old 04-05-2010, 03:45 PM   #8
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Can you give an example of what you can't do; without posting "cat foo.txt > clipboard". What do you intend to do with what winds up in the clipboard?

The most classic example that I can come up with is how to copy text from a browser screen to a gnome terminal. In the browser, merely highlight and CTL-C, and in the terminal use "ALT-P". But, as others mentioned, this is a function of the gnome-terminal.
 
Old 04-08-2010, 01:12 PM   #9
anth0ny5
LQ Newbie
 
Registered: Mar 2010
Posts: 25

Original Poster
Rep: Reputation: 0
To be honest, the idea came from these forums when I wanted to post the output of various logs in pastebin. Gedit garbled some of them and high-lighting from the console seemed primitive, I just thought there would be a better way, like "cat foo.log > clipboard", go to pastebin, ctrl+v.
 
Old 04-08-2010, 01:19 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Well ... to make a long story short: no, there's no way to
avoid those extra utilities. There's no "device node" for
the x-clipboard, or a pipe ... feel free to use the source
of xclip to make one ;}



Cheers,
Tink
 
  


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
Copy an entire document in Vi to clipboard geokker Linux - Newbie 2 08-06-2009 03:14 PM
Copy to Clipboard rubadub Programming 5 02-11-2008 02:39 AM
Copy screenshot to clipboard simbamford Linux - Newbie 1 11-24-2006 03:17 PM
copy from terminal to clipboard curos Linux - Newbie 2 02-04-2006 09:39 AM
how do I copy a selection from xterm to clipboard? hollywoodb Linux - Newbie 1 10-06-2003 12:43 AM

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

All times are GMT -5. The time now is 11:11 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