String Match Comparison

Reply

Join Date: Sep 2006
Posts: 3
Reputation: toztech is an unknown quantity at this point 
Solved Threads: 1
toztech toztech is offline Offline
Newbie Poster

String Match Comparison

 
0
  #1
Sep 8th, 2006
Greetings Guys,

I am currently creating a frontend for a dropable application in Mac OS, for the backend I am using sh/bash.

Currently I have a for look checking to see if it a directory, however I have been unable to find a way to check and see if a string/variable contains .kext.

Mainly I want to check command line arg and throw it in an if != loop if it ($2) does not contain .kext in it.

Regards,

Mofo-X
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 178
Reputation: jim mcnamara is on a distinguished road 
Solved Threads: 10
jim mcnamara jim mcnamara is offline Offline
Junior Poster

Re: String Match Comparison

 
0
  #2
Sep 11th, 2006
This checks $2 to see if ".kext" is anywhere in the $2 parameter
Shell Scripting Syntax (Toggle Plain Text)
  1. echo "$2" | grep -q '.kext'
  2. if [[ $? -eq 0 ]] ; then
  3. echo '.kext found'
  4. else
  5. echo '.kext not found'
  6. fi
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 30
Reputation: sut is an unknown quantity at this point 
Solved Threads: 1
sut sut is offline Offline
Light Poster

Re: String Match Comparison

 
0
  #3
Sep 11th, 2006
Shell Scripting Syntax (Toggle Plain Text)
  1. if [[ $2 != *.kext* ]] ; then
  2. ...
  3. fi
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC