I'm referring to the
&& operators; in particular,
comm2 is typically explained as "execute the
command on the right if the command on the left failed."
I prefer to explain it as an "either-or" construct: "execute either
comm1 or comm2."
While this isn't really precise, let's see what it means in
This means "either cat the files or exit." If you can't cat the files (if cat returns an exit status of 1), you . If you can cat the files, you don't exit; you execute the left side or the right side.
I'm stretching normal terminology a bit here, but I think it's
necessary to clarify the purpose of
By the way, we could
give the poor user an error message before flaming out:
means "execute comm1 AND comm2," or
execute comm2 if comm1 succeeds. (But if you can't
execute the first, don't do any.)
This might be helpful if you want to
print a temporary file and delete it immediately.
lpr file && rm file
If lpr fails for some reason, you want to leave the file around. Again, I want to stress how to read this: print the file and delete it. (Implicitly: if you don't print it, don't delete it.)