Skip to content

Watch output of anything in Bash

2010 October 19
by Tedb0t

Suppose you want to keep a terminal window open showing certain processes, to watch if they’re still alive—you can pipe the output of ps into grep and then into tail:

ps -ef | grep [p]ython | tail -f

The grep pattern searches for “python” but excludes the grep command itself—I’m still not sure why, actually, but it works—at least on Linux.  For some reason, OSX’s bash ignores -f for pipes, so you’d have to use a named pipe or FIFO.  Handy!

Related Posts:

One Response
  1. Aaron permalink
    October 19, 2010

    Weird timing. Igoe just taught us this today in Understanding Networks.

Comments are closed.