Skip to main content
Tweaked wording; fixed punctuation; re-added "shell" tag.
Source Link

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

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 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

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
Added "shell" tag.
Source Link

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 conditional pipeline without saving the result of cmd2cmd2 into a temporary file ? I would think of something like:

cmd1 < input.txt |\
cmd2 |\
(${DEFINED}? cmd3 : cat ) |\
cmd4 |\
cmd5 |\
cmd6 |\
(...) |\
cmdN > result.txt

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 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

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 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
Tweeted twitter.com/#!/StackUnix/status/200544471954358272
deleted 27 characters in body
Source Link
manatwork
  • 32.1k
  • 8
  • 104
  • 93
Loading
Source Link
Pierre
  • 1.8k
  • 3
  • 17
  • 21
Loading