in reply to The simplest (perl) filter for the job

/bin/ps -axwwo command= | perl -pe '$_ = /\.app\/Contents/ && m{([^/]+ +\.app)/} ? $1 : ""'
Update: shorten

Replies are listed 'Best First'.
Re^2: The simplest (perl) filter for the job
by geohar (Acolyte) on Oct 15, 2004 at 10:03 UTC
    Excellent. Though a couple of mods

    /bin/ps -axwwo command= | perl -pe '$_="" if ! /\.app\/Contents/ ; $_ += m{([^/]+\.app)/} ? "$1\n" : ""'

    The expression order needs to be swapped as the previous order stripped off the /Contents before it can be matched by the second expression. Also a space after the '!' prevents tcsh trying to history-expand the search... Thanks

Re^2: The simplest (perl) filter for the job
by geohar (Acolyte) on Oct 15, 2004 at 11:07 UTC
    Yeah, that's nice. Out of interest, is the match guaranteed to return the last match (as in the case of an app in an app) ? It seems to, but I wasn't sure...
      Damn, replying to my own post. The + or * operator seems to leave the bound backref as the last match out of all the repetitions...