If you ever need to quickly paste contents into a file via a shell on linux etc. but don't have a text editor installed (limited distro, jump box etc.) you can use the following command:
cat > myfile.txt << EOF
some test pasted from the cli
pboard including
newlines etc
EOF
-
cat
- print on std out -
> myfile.txt
- redirect std out to myfile.txt (and overwite the contents) -
<< EOF
- Read from the commandline and input will be complete when you see the "EOF" string. - Paste from clipboard (SHIFT+INSERT if CTRL+V doesn't work), type text as needed
- Add one extra newline
- Type "EOF"
- Hit return
Top comments (2)
That's super cool! I appreciate the breakdown at the end, it really helps to clarify the commands, thanks for the post!
Glad you found it useful - I'm no shell expert but it helped me to understand the different pieces. I needed this on a remote jump box with SSH disabled and no editors installed where I needed to send over a new key-file.