http://justcoding.iteye.com/blog/1829963
1. Under Windows
Use the command that comes with your system clip
.
# is located C:\Windows\system32\clip.exe
.
Example:
C code
- echo Hello | Clip
- # put the string hello into the Windows clipboard
- Dir | Clip
- # put the dir command output (current directory list) into the Windows clipboard
- Clip < README. Txt
- # put Readme.txt text in the Windows clipboard
- echo | Clip
- # Place a blank line into the Windows clipboard, which clears the Windows clipboard
2. Under Ubuntu
Users under Ubuntu can install with Apt-get only:
C code
- sudo apt-get install Xclip
Other releases of the user can choose their own installation method, can also be compiled with the source code installation, Xclip project's home page is: http://sourceforge.net/projects/xclip/
The Xclip can output content to the ' X ' clipboard, such as:
C code
- Echo "Hello, World" | Xclip
After executing this command, you can use the middle mouse button to paste the content in the X program. But more often than not just outputting the content to the ' X ' clipboard, we want to be able to paste it in the GUI program (for example, in the Gnome clipboard), and the following command lets you output the content to Gnome's clipboard:
C code
- Echo "Hello, World" | xclip-selection clipboard
Then press CTRL + V in a GUI program to see if it's pasted up? Following this command, I also re-wrote the ifconfig, let it input content to the terminal after execution, but also output the IP address to the Clipboard, because generally, the view ifconfig is to obtain the machine's IP address:
C code
- Alias ifconfig='/sbin/ifconfig && echo '/sbin/ifconfig | sed-n 2p | awk "{print \\$2}" | grep-o "[0-9]\{1, 3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\} ' | xclip-selection Clipboard '
Or
C code
- Xclip-sel Clip < file
You can then CTRL + V on the page and other edit boxes.
Project home: http://sourceforge.net/projects/xclip/
Command Man Page:http://linux.die.net/man/1/xclip
- I.,
-inRead text to X selection from standard input or files (default)
- o,
-outPrints the selection to standard out (generally-piping to a-file or program)
- F,
-filterWhen Xclip was invoked in the on mode with output level set to silent (the defaults), the filter option would cause Xclip to Print the text piped to standard on back to standard out unmodified
- L,
-loopsNumber of X selection requests (pastes into X applications) to wait for before exiting, with a value of 0 (default) causin G Xclip to wait for an unlimited number of requests until another application (possibly another invocation of Xclip) takes Ownership of the selection
- D,
-displayX display to use (e.g. "localhost:0"), Xclip defaults to the value in $
DISPLAYIf this option is omitted
3. Under Linux
Use the xsel
command.
Example:
C code
- Cat README. TXT | Xsel
- Cat README. TXT | Xsel-b # If you have questions, try the-B option
- Xsel < README. Txt
- # put Readme.txt text in the Clipboard
- Xsel-c
- # Empty the Clipboard
4. Under Mac
Use the pbcopy
command. # There should be a pbpaste
command.
Example:
C code
- echo ' Hello world! ' | pbcopy
- # Put the string Hello World into the Clipboard
C code
- Cat MyFile.txt | Pbcopy
C code
- Pbpaste > File.txt
to copy the results and to see the output of the command
Command output is not visible if you give the Copy command (the above-mentioned command, clip, Xsel, pbcopy). If you want to see the output of the command first, you can do so below.
C code
- $ echo ' Hello world! ' | tee tmp.file.txt
- Hello world!
- $ Xsel < Tmp.file.txt
- $ RM tmp.file.txt
That is, first use
tee
command to export the output to the console and to a file. After the command executes, the output is then placed on the Clipboard.
copy SSH's public key
Use the following command:
C code
- $ pbcopy < ~/.ssh/id_rsa.pub
Note: Different systems use different copy commands. Avoid using a text editor to open this file, select text, CTRL + C as a tedious operation.
Linux:xclip,pbcopy,xsel usage terminal copy sticky sticker (Mac, Ubuntu)