Skip to content
Advertisement

why doesn’t watch work when piping the output of fortune into cowsay

cowsay is a silly linux tool for displaying a cow saying given text in the terminal.

JavaScript

fortune is a silly linux too for displaying a “random” quote in the terminal.

JavaScript

Both of these commands can be repeatedly ran in the terminal using watch e.g.

JavaScript

Additionally these two commands can be combined so the cow says “random” quotes. By piping the output of fortune into cowsay.

JavaScript

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

JavaScript

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

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement