I needed to write a script to enter multi-line input to a program (psql
).
After a bit of googling, I found the following syntax works:
c
Using tee instead of cat
Not exactly as an answer to the original question, but I wanted to share this anyway: I had the need to create a config file in a directory that required root rights.
The following does not work for that case:
$ sudo cat </etc/somedir/foo.conf
# my config file
foo=bar
EOF
because the redirection is handled outside of the sudo context.
I ended up using this instead:
$ sudo tee </dev/null
# my config file
foo=bar
EOF