OpenBSD Journal

Text Searching Tools

Contributed by jose on from the needles-and-haystacks dept.

While basic use of grep is in most people's skills, a Sysadmin magazine article on some of the lesser known features of searching may be worth checking out. Included are two grep-like tools for other data sources, ngrep , which can grep through network packets, and grepmail , which can sort through mail (compressed or not) and return the results. All in all some handy stuff, some of which may be useful for your OpenBSD usage.

(Comments are closed)

  1. By Anonymous Coward () on

    Both appear in the ports... and are not available in the base

  2. By Justin () on

    Ahhhh, grep this!

    I always wanted to say that. :)

    I wish I didn't have to 'grep -v grep'
    $ps ax |grep SOME_PROCESS |grep -v grep
    I should write a psgrep shell script to do this.

    ps ax |grep $1 |grep -v grep

    1. By Evan () on

      Try this instead: ps ax | grep [S]OME_PROCESS For example: ps ax | grep [v]im Will show all vim processes that are running but will not match the ps | grep expression because the regexp is hidden.

      1. By Justin () on

        That's a good one too. There are usually so many ways to do one thing (in Open Source anyways).

        1. By nhoj () on

          I think the point is that he wants the command from solaris that does it for you :)

    2. By jose () on

      if all you care about is process names try the -c flag to ps, shows only argv[0] (the command name). grep wont match then. ie "ps -axc | grep named" ...

      an alternative is to use awk:

      ps -ax | awk '{if ($5 == "named") print $1}'

      will also print out the PID. tweak accordingly (ie use ARGV[] in that awk one liner).

    3. By Will Dyke () on

      Had a look on sourceforge for pgrep, and found proctools at Only in beta at the moment, unfortunately. pgrep and pkill were two of my favourite commands when I was administrating solaris boxes.

      1. By Anonymous Coward () on

        Only in beta at the moment

        Just installed it and seems to be working pretty decently so far. Thanks.

    4. By Anonymous Coward () on

      alias pid='ps -awwwwx | grep -v grep | grep '

      $ pid foobar

      ('pid' name stolen from bsdi?)

Latest Articles


Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]