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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
read metacharacter [ and ] kamel.seg Shell Programming and Scripting 2 01-15-2008 10:21 AM
compare null with non-null nitin Shell Programming and Scripting 8 11-04-2006 04:58 PM
Null Value Khoomfire UNIX for Advanced & Expert Users 1 04-10-2006 06:55 AM
Q1 :/dev/null Q2 -A big123456 UNIX for Advanced & Expert Users 4 11-09-2005 11:16 PM
>/dev/null piltrafa UNIX for Dummies Questions & Answers 1 10-26-2001 02:46 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-25-2006
Registered User
 

Join Date: Jan 2006
Posts: 2
Null metacharacter?

Ok, here's what I'm trying to do:

I'm trying to formulate an <expression> that will match any of the following:

*.jpeg
*.jpg
*.JPEG
*.JPG

for a 'find <directory> -name <expression> ' command. I'd like to do *.[jJ][pP][eE<null>][gG], but don't know what the null character is, or even if it exists. Any thoughts on how to implement this? Thanks.
Reply With Quote
Forum Sponsor
  #2  
Old 01-25-2006
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
how about
find . -name "*.[jJ][pP]*[gG]"
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
  #3  
Old 01-25-2006
Registered User
 

Join Date: Jan 2006
Posts: 2
Sure, I thought about that, but that would match *.jpig, *.jpog, *.jpanythingyouwantg, etc. I'm looking for a more exact expression. Obviously your suggestion would work 99.999999% of the time though. I think an even better one would be *.[jJ][pP]?[gG] since ? restricts the wildcard to a single character, but still not quite what I'm looking for.
Reply With Quote
  #4  
Old 01-25-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
I'm not sure why you think you need this, ASCII NUL is the end of a string. The dirent struct member d_name is a char *. So it will be interpreted as ending with the character before the NUL.

the null character is
Code:
\000
Reply With Quote
  #5  
Old 01-25-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,656
Quote:
Originally Posted by kidcharles
I'm looking for a more exact expression.
find <directory> -name *.jpeg -o -name *.jpg -o -name *.JPEG -o *.JPG
Reply With Quote
  #6  
Old 01-26-2006
Registered User
 

Join Date: Jan 2006
Posts: 7
try : (space)
Code:
\b
Reply With Quote
  #7  
Old 01-27-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
There is no null character in file pattern-matching
Code:
find <directory> -name '*.[jJ][pP][gG]' -o -name '*.[jJ][pP][eE][gG]'
Jean-Pierre
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0