xsel
I am using xsel Install xsel, but I am only using it with plain text and unicode text.
xsel
can copy and paste to three different "clipboards".
By default, it uses the X Window System primary selection, which is basically whatever is currently in selection. The X Window System also has a secondary selection (which isn't used much), and a clipboard selection. You're probably looking for the clipboard selection, since that's what the desktop environment (e.g. Gnome, KDE, XFCE) uses for its clipboard. To use that with xsel:
xsel --clipboard < new-clipboard-contents.txt
xsel --clipboard > current-clipboard-contents.txt
When you press Ctrl-C over a file in the file manager, the file's contents IS NOT copied to the clipboard. A simple test: select a file in file manager, press Ctrl-C, open a text editor, press Ctrl-V. The result is not file's contents but its full path.
In reality the situation is a bit more complicated because you can't do the opposite - copy a list of filenames from a text editor and paste them into file manager.
To copy some data from command line to X11 clipboard you can use xclip
command, which can be installed with
sudo apt-get install xclip
to copy contents of a file or output of some command to clipboard use
cat ./myfile.txt|xclip -i
the text can be then pasted somewhere using middle mouse button (this is called "primary selection buffer").
If you want to copy data to the "clipboard" selection, so it can be pasted into an application with Ctrl-V, you can do
cat ./myfile.txt|xclip -i -selection clipboard
To be able to copy files from the command line and paste them in a file manager, you need to specify a correct "target atom" so the file manager recognizes the data in the clipboard, and also provide the data in correct format - luckily, in case of copying files in a file manager it's just a list of absolute filenames, each on a new line, something which is easy to generate using find
command:
find ${PWD} -name "*.pdf"| xclip -i -selection clipboard -t text/uri-list
(at least this works for me in KDE). Now you can wrap into a small script which you can call, say, cb
:
#!/bin/sh
xclip -i -selection clipboard -t text/uri-list
then you put it in ~/bin
, set executable bit on it and use it like this:
find ${PWD} -name "*.txt"| cb
Nice, isn't it?
Best Answer
Simple: type in terminal
For copy
and for more info about
cp
useman cp
For cut(move and rename)
and for more info about
mv
useman mv