Bash Shell Scripting
Crash Course
crowfly.net

<<   >>

Introduction

GNU_Tools

Example1

Example2

Execution_bit

Bang_bin_bash

Example3

The_dot

Example4

Example5

Example6

Example7

Example8

Background

Forking

Example9

Bash_profile

Pattern_match

Regex

Debug

Gory_details

References

<<   >>
Example 5

psgrep

  ps -ef | grep $*

Output looks like this:

  dlink@viddev1> psgrep dlink
  lp        5830  5322  0 Jun26 ?        00:00:00 /usr/bin/perl /usr/lib/cups/filter/foomatic-rip 63 dlink (stdin) 1 
  lp        5855  5322  0 Jun26 ?        00:00:00 socket://192.168.1.100:9100 63 dlink (stdin) 1 
  lp        5930  5830  0 Jun26 ?        00:00:00 /usr/bin/perl /usr/lib/cups/filter/foomatic-rip 63 dlink (stdin) 1 
  lp        5933  5930  0 Jun26 ?        00:00:00 /usr/bin/perl /usr/lib/cups/filter/foomatic-rip 63 dlink (stdin) 1 
  root     28905     1  0 Jun27 ?        00:00:00 /sbin/mount.smbfs //halfpint/videoproject /netbackup -o rw username dlink password XXXXXXXX
  root     20827  5335  0 09:48 ?        00:00:00 sshd: dlink [priv]                              
  dlink    20829 20827  0 09:48 ?        00:00:09 sshd: dlink@notty                               
  dlink    20830 20829  0 09:48 ?        00:00:00 /usr/bin/X11/xterm -ls -bg FloralWhite -fg black -fn 10x20 -T viddev1
  dlink    20837 20830  0 09:48 pts/0    00:00:00 -bash
  dlink    25541 20837  0 11:14 pts/0    00:00:26 emacs -T E viddev1 .
  dlink     3069 20837  0 14:08 pts/0    00:00:00 -bash
  dlink     3070  3069  0 14:08 pts/0    00:00:00 ps -ef
  dlink     3071  3069  0 14:08 pts/0    00:00:00 grep dlink
  dlink@viddev1> psgrep httpd
  root      6993     1  0 Jun26 ?        00:00:04 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  wwwrun   29913  6993  0 Jul11 ?        00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  wwwrun   29914  6993  0 Jul11 ?        00:00:02 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  wwwrun   29915  6993  0 Jul11 ?        00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  wwwrun   29916  6993  0 Jul11 ?        00:00:02 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  wwwrun   29917  6993  0 Jul11 ?        00:00:01 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  wwwrun   30237  6993  0 Jul11 ?        00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  wwwrun   31281  6993  0 Jul11 ?        00:00:02 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  wwwrun   18202  6993  0 Jul11 ?        00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
  dlink     4094  4091  0 14:11 pts/0    00:00:00 grep httpd
  dlink@viddev1> psgrep post | grep -v postfix
  postgres 11380     1  0 Jul13 ?        00:00:03 /usr/local/pgsql813/bin/postmaster -D /db/pgsql813 -i
  postgres 11382 11380  0 Jul13 ?        00:00:01 postgres: writer process                             
  postgres 11383 11380  0 Jul13 ?        00:00:25 postgres: stats buffer process                       
  postgres 11385 11383  0 Jul13 ?        00:02:21 postgres: stats collector process                    
  dlink     4715  4711  0 14:12 pts/0    00:00:00 grep post