Say I've got the following pipeline:
cmd1 < input.txt |\
cmd2 |\
cmd4 |\
cmd5 |\
cmd6 |\
(...) |\
cmdN > result.txt
Under certain conditions I would like to add a cmd3 between cmd2 and cmd4. Is there a way to create a kind of conditional pipeline without saving the result of cmd2 into a temporary file ? I would think of something like:
cmd1 < input.txt |\
cmd2 |\
(${DEFINED}? cmd3 : cat ) |\
cmd4 |\
cmd5 |\
cmd6 |\
(...) |\
cmdN > result.txt