Re: test for a pattern in sh?



stan <stanb@xxxxxxxxx> 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/>

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



Relevant Pages

  • Re: indices into an array
    ... My real array is much larger than the example above ... var filteredArray = a.filter( ... At least the for-loop is probably executed in already compiled code then, ... want the matching values, or the matching indexes? ...
    (comp.lang.javascript)
  • Re: test for a pattern in sh?
    ... I found some examples for patterm`n matching with case, ... reaher use an if here, if I can do pattern matching with it. ... The term ${VAR#*SV} is the same as $VAR if there is no SV in it. ... Otherwise $removes the first part of the string including the ...
    (Ubuntu)
  • Re: getElementById in MSIE
    ... name matching. ... So how about replacing getElementById conditionally, after a feature ... var d = document, el = d.getElementById, els,i, len; ... els = d.getElementsByName; ...
    (comp.lang.javascript)
  • test for a pattern in sh?
    ... if $VAR does not contain SV do something ... I found some examples for patterm`n matching with case, but I'd reaher use ... they had no way to indicate successful termination of their C ...
    (Ubuntu)
  • Re: Inserting Table Rows conditionally
    ... my point in posting was to ask how I could insert a row header ... rows with a matching "H:" and have the row text be the ... var theRows = document.getElementsByTagName; ...
    (comp.lang.javascript)