Can we copy a string with a command-line and have the ability of pasting it with Ctrl + V shortcut?
Ubuntu – Copy “string” through command line
command linescripts
command linescripts
Can we copy a string with a command-line and have the ability of pasting it with Ctrl + V shortcut?
Best Answer
Yes. You can use
xsel
tool (a command-line tool to access X clipboard and selection buffers). To install it from terminal, use the following command:Then, using the following:
will copy the output of
<command>
to the clipboard which can be pasted after with Ctrl + V.For example:
or, simple:
will copy to the clipboard the string
string
(I used-n
argument forecho
to suppress the trailing newline).If you want to copy the text from a file named
file_name
from the current working directory:or, simple: