LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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



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: test for substring inside string ali_bush Linux - General 3 04-26-2018 07:31 PM
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
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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration