In this post, Stephen's answer displays this code:
cat <<-"EOF1" >> myPath/myFile.append
if ! grep -F -q -f myPath/myFile{.append,}; then
cat myPath/myFile.append >> myPath/myFile
fi
How come there is no delimiter to the heredocument?
In this post, Stephen's answer displays this code:
cat <<-"EOF1" >> myPath/myFile.append
if ! grep -F -q -f myPath/myFile{.append,}; then
cat myPath/myFile.append >> myPath/myFile
fi
How come there is no delimiter to the heredocument?
All shells I tested read a here-document just fine even without the terminator, the here-doc will just end at end-of-file then. Bash gives a warning about this, but busybox/dash/ksh and zsh just handle it silently.
E.g.
$ cat heredoctest.sh
#!/bin/bash
cat -n <<EOF
foo
bar
$ bash heredoctest.sh
heredoctest.sh: line 4: warning: here-document at line 2 delimited by end-of-file (wanted `EOF')
1 foo
2 bar
But the particular sample of code you present seems like an error. As it's written, it would just append the if-statement to myPath/myFile.append
, which doesn't seem too useful. It looks like the here-doc contents and the terminator are just missing from between the cat
and the if
.
EOF1
somewhere, probably just after "content" is stored insidemyFile.append
. – jimmij Jun 16 '18 at 19:06