3 ms·
Re: long pipelines, the guide suggests: # Long commands command1 \ | command2 \ | command3 \ | command4 However, by ending each line with the
by js2 13y ago
Re: long pipelines, the guide suggests:
# Long commands
command1 \
| command2 \
| command3 \
| command4
However, by ending each line with the pipe the continuation is implicit and the backslashes may be omitted:
# Long commands
command1 |
command2 |
command3 |
command4
- deleted 13y ago[deleted]
- dredmorbius 13y agoPipes, and logical operators (&&, ||) can continue lines in bash. I find it convenient, and generally clear, to break longer constructions using these operators with them.
- emmelaich 13y agoI usually use the trailing | but I can certainly see the sense in the leading pipe. It makes it clearer that the lines following are continuations; especially the last in the pipeline.
- sesqu 13y agoI consider the leading pipe clearer, and could be sold on it, but ending each line with an inconvenient slash character (non-US layout) makes me strongly favor the trailing version. The trailing version seems more natural with operators like comma, but less natural with operators like minus, and is far clearer with semicolonless languages. I suspect if I were to go through old code, I'd find both uses, but generally I prefer trailing. The exception to this is languages like Haskell, though indentation could serve the same purpose.