| | |
String Match Comparison
![]() |
•
•
Join Date: Sep 2006
Posts: 3
Reputation:
Solved Threads: 1
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
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
•
•
Join Date: May 2004
Posts: 178
Reputation:
Solved Threads: 10
This checks $2 to see if ".kext" is anywhere in the $2 parameter
Shell Scripting Syntax (Toggle Plain Text)
echo "$2" | grep -q '.kext' if [[ $? -eq 0 ]] ; then echo '.kext found' else echo '.kext not found' fi
•
•
Join Date: Sep 2006
Posts: 30
Reputation:
Solved Threads: 1
Shell Scripting Syntax (Toggle Plain Text)
if [[ $2 != *.kext* ]] ; then ... fi
![]() |
Similar Threads
- why gets() is skip in this program? (C++)
- Comparing two letters in one string with another char string? (C)
- Getting the start / end of string in regex through match objects (Python)
- Chaintech BIOS Lock String (Motherboards, CPUs and RAM)
- How DO you count Upper Case letters? (Java)
- Lines are being skipped in the input file. (Visual Basic 4 / 5 / 6)
Other Threads in the Shell Scripting Forum
- Previous Thread: Making a shell script executable from any directory
- Next Thread: Replace text in a file
| Thread Tools | Search this Thread |





