How to write clipboard into the file?

Many times when I bowse the internet I copy some text from web page, open nano with command
nano some.txt, paste copied text and then save it.
(i prefer command line this case but I use XFCE so if there is a GUI way I would like to know it too)

Is there a command like (this is my imagination)
saveclipboardtofile --file=some.txt

I would check if xclipboard or Clipman could be a solution.

Further tools:
https://wiki.archlinux.org/index.php/Clipboard

2 Likes

If I understand you correctly, then what you wish to do is paste the contents of the clipboard into a terminal window, with or without a character-mode application running, is that correct?

If so, it’s not that hard. Just position the cursor where you want the contents of the clipboard pasted, and then press Ctrl+Shift+V.

Now, you’re running XFCE, and I myself am running Plasma, so I don’t know whether the following shortcut is supported in XFCE too, but in Plasma, you can also use Shift+Ins, which works in both character-mode applications in a terminal and in GUI applications.

Hope this helps. :wink:

1 Like

There is two commandline apps handling such case

sudo pacman -Syu xclip xsel

Copy some text from a web page and in terminal do

$ xclip -out -selection clipboard > test.txt
2 Likes

I’ll look into that.

Not exackly.
I would like to copy (or mark some text in Firefox) and then, in terminal I would like to use a command that will save copied text into the text file. Without even opening vim or nano

1 Like

You can simply use echo and bash’s built-in file commands > and >> (> overwrite output to file, and >> to append output to file).

For example, to create a new file with with pasted text

echo ' < paste text > ' > some.txt

The single quotes are to help the pasted text be interpreted as one string.


If your clipboard manager has the facility to output a copied item/s via terminal you may be able to do it a bit cleaner (as linux-aarhus mentioned). I use copyq and this command works for me, I still use echo so a newline is appended to the string. Using the append flavor (>>).

echo $(copyq read) >> some.txt


more info on bash file commands

more info on copyq
https://hluk.github.io/CopyQ/

1 Like