I have a single line of about 30000 characters (and no newline) in my clipboard. I want to put that into a file. I tried the following command in a GNOME terminal (Ubuntu 20.04):
cat > file.ext
and then pasted the line using shift+ctrl+V
.
The file ended up with only 4096 characters.
I can successfully create the file by typing
gedit file.ext
and then pasting the line with ctrl+V
and closing the text editor. But why can't I do it with a command-line utility like cat
?
cat
isn't the issue. I don't know what is, but it isn'tcat
– Chris Davies Aug 16 '23 at 10:45man xsel
. xsel can work with the primary selection, secondary selection, or the clipboard (and note that the interactions between these three and your terminal and various apps takes some getting used to). xsel can read from stdin or write to stdout. BTW, I occasionally (at least once a week or so) use xsel to copy/paste very large text selections (tens of thousands of lines - because it's much easier to pipe something intoxsel -i
than it is to manually select & copy it from the terminal buffer) – cas Aug 16 '23 at 14:30