test for a pattern in sh?

Florian Diesch diesch at spamfence.net
Sun Oct 11 19:03:15 UTC 2009


stan <stanb at panix.com> writes:

> I need to do something like this:
>
> if $VAR does not contain SV do something
>
> I found some examples for patterm`n matching with case, but I'd reaher use
> an if here, if I can do pattern matching with it.

  if ! echo "$VAR"|grep -q SV; then 
    do_something 
  fi

or

   echo "$VAR"|grep -q SV || do_something 



   Florian
-- 
<http://www.florian-diesch.de/software/shell-scripts/>




More information about the ubuntu-users mailing list