Translate

Wednesday, March 18, 2026

Use Pipe Output in multiple commands

If multiple lines send to fzf, otherwise just print the single line

printf "ONE\nTWO\nTHREE\nFOUR\n" |  { X=$(tee);  LX=$(echo "${X}" | wc -l);  [ ${LX} -gt 1 ] && (echo "${X}" | fzf) || echo  "${X}"; }
>
| ONE   |
| TWO  |
| TREE |

printf "ONE" |  { X=$(tee);  LX=$(echo "${X}" | wc -l);  [ ${LX} -gt 1 ] && (echo "${X}" | fzf) || echo  "${X}"; }

> ONE

Send output to multiple commands

 printf "ONE\nTWO\THREE\nFOUR\n" |   tee >(cmd1) >(cmd2)

No comments:

Blog Archive