cowsay is a silly linux tool for displaying a cow saying given text in the terminal.
$ cowsay hello
fortune is a silly linux too for displaying a “random” quote in the terminal.
$ fortune
Both of these commands can be repeatedly ran in the terminal using watch e.g.
$ watch cowsay hello $ watch fortune
Additionally these two commands can be combined so the cow says “random” quotes. By piping the output of fortune into cowsay.
$ fortune | cowsay
However a combination of the use of watch and piping the output of fortune into cowsay doesn’t do anything…. i.e. hangs until the process is ended
$ watch fortune | cowsay
Does anyone know why?
Advertisement
Answer
With watch fortune | cowsay you are piping the output of watch fortune into cowsay. You want to watch the value of fortune piped to cowsay so you should quote it so watch will get the whole command to execute as
watch 'fortune | cowsay'