Register a domain and help support LQ
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-10-2010, 06:45 AM   #1
LQ Newbie
Registered: Jul 2010
Distribution: Ubuntu 10.10
Posts: 22

Rep: Reputation: 0
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:

for x in $*
	if [ "$x" = "*.DNG" ]
		then zenity --info --text="$x"
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?
Old 07-10-2010, 06:52 AM   #2
LQ Newbie
Registered: Jul 2010
Distribution: Ubuntu 10.10
Posts: 22

Original Poster
Rep: Reputation: 0
Never mind... Should have used [[ and ]].


bash, condition, conditional, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to test string complexity (like password complexity) robertjinx Linux - Server 2 05-12-2010 03:58 PM
Bash Script to get the first characters of a string onesikgypo Programming 12 11-14-2008 10:57 AM
bash: test for substring inside string ali_bush Linux - General 1 03-08-2007 05:34 PM
String manipulation with BASH script King V Programming 9 04-21-2006 04:15 PM
looking for string on particular line - bash script tara Linux - General 9 12-14-2005 06:43 PM

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration