LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash script: How to test string value? (https://www.linuxquestions.org/questions/programming-9/bash-script-how-to-test-string-value-819058/)

KonfuseKitty 07-10-2010 05:45 AM

Bash script: How to test string value?
 
Apologies for such a basic question, but I keep reading about bash and trying different things to no avail.

I have this script that I run on a number of selected files. The pathnames of the files are passed to the script in value $*. For every selected file with the type extension of .DNG, a zenity dialog should come up. Here's the script:

Code:

#!/bin/bash
for x in $*
do
        if [ "$x" = "*.DNG" ]
                then zenity --info --text="$x"
        fi
done
exit 0

My test [ "$x" = "*.DNG" ] is obviously wrong. But I've tried it without quotes and it also doesn't work. How should this be stated to work?

KonfuseKitty 07-10-2010 05:52 AM

Never mind... Should have used [[ and ]].


All times are GMT -5. The time now is 05:03 PM.