I have seen this construct in scripts a lot and used it myself, but it bothers me that I can't seem to find it in the documentation.
Example:
[ -f file1 ] &&
[ -f file2 ] &&
echo "Both files exist." ||
echo "One or the other file doesn't exist."
This could also be done with backslashes before the newlines, as mentioned in man bash
:
If a \<newline> pair appears, and the backslash is not
itself quoted, the \<newline> is treated as a line continuation (that
is, it is removed from the input stream and effectively ignored).
Example:
[ -f file1 ] && \
[ -f file2 ] && \
echo "Both files exist." || \
echo "One or the other file doesn't exist."
...but this doesn't seem to be necessary. The first version above works even without the backslashes.
Where can I find this in man bash
? (Also, is this bash
specific or POSIX compliant?)
;
,&
,(
and)
.names=( Rama Soma<newline> Sita Diya )
. Python clearly describes these here but the Bash documentation doesn't seem to.