Bash: Split Long Lines
Sometimes a statement is so long that it exceeds a reasonable line length (perhaps 80 characters as recommended by some style guides).
cmd | cmd | cmd | cmd
When a line exceeds the number of characters you decided to use in your scripts, or when it becomes hard to read, that’s when you should probably split your line into multiple lines like this:
| cmd \
| cmd \
\ for splitting. There are some other recommendations that make such a split more readable:
- add a two-space (or whatever your script already uses) indent at the beginning of each line
|right after the indent
All this also goes for
&& cmd \
You can even use the same principle with a command that has many options:
--option-two param \
I’d argue that this is much more readable than cramming all the options on one line.