Thank you for your support. I wish to make a bash script that uses the latest text copied and currently in clipboard.
3 Answers
You can leverage xdotool for simulating the keyboard and mouse.
So for pasting a text from clipboard we use Ctrl+Shift+v, you can simulate this in xdotool by:
xdotool key ctrl+shift+v
Also check of mouse actions, read man xdotool.
If not installed, install it by (available in the Universe repository):
sudo apt-get install xdotool
- 93,925
There are keyboard shortcuts for GUI terminals , Ctrl+Shift+V and Shift+Insert already. A script and mouse are unnecessary here.
If you're specifically looking for commands, there are xclip and xsel. Both of them are used to manipulate clipboards ( of which there are two in Linux - primary and secondary, that's why two different keyboard shortcuts were mentioned in the beginning of this answer ). I am personally more of a xclip fan, and i regularly use echo text | xclip -sel clip to copy something to clipboard and xclip -out -sel clip to print out whatever is in my clipboard. This is especially useful when you want to filter out text or process text with another command like xclip -out -sel clip | grep 'some text that I am looking for'
NOTE: xclip and xsel don't come to Ubuntu by default. You must install them with sudo apt-get install PACKAGE_NAME command
If we want to go into TTY, there's no way to copy text there. You must either use something known as named pipe or just a plain text file.
- 107,582
I found a solution while i was surfing trhough this forum. i had to install "xclip"
sudo apt-get install xclip
then i use it in the terminal:
"$(xclip -o)"
- 81