[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need help on shell programming



On Sun, Mar 08, 2009 at 08:50:25PM +0100, Michael Wagner wrote:

> -----------------------------------------------------+
> #! /bin/bash                                         |
>                                                      |
> if [ $(pgrep -x script.sh) ]; then <script here>; fi |

Again: if runs a command as a test. Using '[' (test) is not a
requirement.

if pgrep -x script.sh >/dev/null; then ...

(The above would also be a syntax error if you get two matches)

-- 
Tzafrir Cohen         | tzafrir@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir@cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend


Reply to: