LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 07-10-2010, 05:45 AM   #1
KonfuseKitty
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:

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?
 
Old 07-10-2010, 05:52 AM   #2
KonfuseKitty
LQ Newbie
 
Registered: Jul 2010
Distribution: Ubuntu 10.10
Posts: 22

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


Reply

Tags
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 02:58 PM
Bash Script to get the first characters of a string onesikgypo Programming 12 11-14-2008 09:57 AM
bash: test for substring inside string ali_bush Linux - General 1 03-08-2007 04:34 PM
String manipulation with BASH script King V Programming 9 04-21-2006 03:15 PM
looking for string on particular line - bash script tara Linux - General 9 12-14-2005 05:43 PM


All times are GMT -5. The time now is 09:07 PM.

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