The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-26-2006
josephwong josephwong is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 4
How to check a string in the variable

hi,

I have a variable var1 as follows in the script.

var1="one two three desformat=PDF xyz"
I would like to check whether $var1 has a string "desformat=PDF" or not.

Is there any command I can use (not need to creat a file)?

Currently, I am using this:

if ( grep "desformat=PDF" $chkpdf 1>/dev/null )
then
--$chkpdf is a file contains the string a parameter

Thanks.

Cheers,
Joseph