The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help--Using wildcards in string comparison deepae Shell Programming and Scripting 2 05-06-2009 02:01 PM
Find the position of a string and replace with another string bab123 Shell Programming and Scripting 6 01-21-2009 04:14 AM
Read a string with leading spaces and find the length of the string dayamatrix UNIX for Dummies Questions & Answers 2 11-13-2008 10:08 AM
counting a list of string in a list of txt files Pep Puigvert UNIX for Dummies Questions & Answers 4 08-15-2008 04:55 PM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 06:38 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-25-2009
Johan III Johan III is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 4
Find string in list with wildcards

I need to add code to a shell script to find out if a string matches any item in a list, where the list can contain a wildcard character.

For example, if I have the following list:
ok_versions="03-02-4, 04-01-*"

Then I want to compare a particular string to see if it matches any item in the list. For example, I could have a string like the following
my_version="04-01-2".

I want to check my_version against ok_versions, and note that my_version is ok if it is 03-02-4, 04-01-1, 04-01-2, etc., but that it is not ok if it doesn't match one of the patterns. The ok_versions list could have any number of entries (not just two).

I am new to shell scripting and would really appreciate anyone who can solve this problem for me.

Thanks!
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0