I am writing a bash script to look for a file if it doesn't exist then create it and append this to it:
Host localhost
ForwardAgent yes
So "line then new line 'tab' then text"
I think its a sensitive format.
I know you can do this:
cat temp.txt >> data.txt
But it seems weird since its two lines. Is there a way to append that in this format:
echo "hello" >> greetings.txt
( echo "line 1" ; echo "line 2" ) >>greetings.txt
. – ott-- May 27 '13 at 15:38{ echo "line 1" ; echo "line 2"; } >>greetings.txt
– Hauke Laging May 27 '13 at 16:10{}
is the better idea. – ott-- May 27 '13 at 18:02echo
supports-e
, so that's another possibility. Also,$'line1\nline2\nline3'
is another bash feature. – derobert Sep 05 '14 at 20:43cat <<EOT
theEOT
is just a random string. Could becat <<FOO
, too. – Hauke Laging Jan 09 '16 at 20:37cat <<EOT
otherscat <<"EOT"
and some evencat <<'EOT'
. Don't we need to quote it? What are the downsides of not quoting? – TCB13 Jan 26 '19 at 22:55EOT
is quoted (somehow) determines whether parameter expansion, command substitution, and arithmetic expansion are applied to the lines. – Hauke Laging Jan 30 '19 at 15:02cat <<"EOT" ... EOT
prevents expansion of parameters and shell variables. – tillmo Feb 02 '19 at 19:38EOT, EOL, EOF
acronyms stand forend of transmission/line/file
respectively – whyer Nov 24 '19 at 14:22<<EOT
evaluates some of my commands unfortunately. – Alexandre A. Apr 08 '20 at 11:54<<"EOT"
Now that I have written this I notice that this has been answered already, to comments before yours. – Hauke Laging Apr 15 '20 at 16:51