This is a particularly complex example because some of the \
there are what you're calling "line-continuation" but others are to protect characters so the shell doesn't interpret them and instead passes them to find
. Specifically, the \(
, \)
and \;
are there so that the shell doesn't interpret the escaped characters and passes them as-is to find
. The rest, the \
that aren't immediately before a non-space character are line continuation signals.
In general, if you want to break a command, you need the \
unless you break on one of the "list terminator" characters. So, if you cut after one of these, you don't need the \
:
; & && || | |& ;;
For example, echo foo && echo bar
can be written as:
echo foo &&
echo bar
No need for \
. Alternatively, the same thing can also be written as:
echo \
foo \
&&
echo \
bar
Note how I have used the \
when cutting at places that are neither the end of a command nor a list terminator.
If you cut a command anywhere else, you need the \
. You don't need the \
in the if ... then ... else ...
example you show because there, you aren't cutting a command. Each command is on its own line, and that's fine. You only need the \
if you want to break a single command onto multiple lines.
As @paul_pedant correctly pointed out in the comments, you can make the command much clearer if you use single quotes to escape things for find
:
find playground \
'(' \
-type f \
-not -perm 0600 \
-exec chmod 0600 {} ';' \
')' \
-or \
'('
other options...
')'
if
,for
,while
,case
are control structures. The\\
just allows you to continue a command in a new line. – schrodingerscatcuriosity Mar 05 '20 at 13:16