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

Recommended Answers

All 2 Replies

This checks $2 to see if ".kext" is anywhere in the $2 parameter

echo "$2" | grep -q '.kext'
if [[ $? -eq 0 ]] ; then   
  echo '.kext found'
else
  echo '.kext not found'
fi
if [[ $2 != *.kext* ]] ; then
   ...
fi
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.