I want to paste some text into a terminal and save it to a file without using an editor, but just 'cat'.
But too long lines or tabs in text make it impossible to do so with a simple command like "cat >test.txt" or "cat <<'EOF' >test.txt" ("here document").
In bash in "here document" mode if pasted text data contains tabs, they cause autocomplete.
If I start bash with '--noediting', on some systems the length of pasted line is limited to 256 chars, the rest of pasted text is discarded.
If instead I paste directly to cat's input (without <<'EOF'), the max line is also 256.
If I do:
stty raw; cat >test.txt; stty sane
, the line length is no longer limited, but there's no way to send EOF to cat's input.
If I enable eof char:
stty raw icanon eof '^d'; cat >test.txt; stty sane
long lines are lost.
Also, if I don't disable echo with:
, the combination of Solaris 10 and Putty cause large blocks of text ~1500chars to be lost, sometimes resulting an empty file.
The closest I got to what I want is to kill cat with timeout:
( sleep 15; pkill cat ) & stty raw -echo; cat >test.txt; stty sane; echo done
or to use bash --noediting with raw:
bash --noediting stty raw -echo icrnl cat <<'EOF' >test.txt; stty sane