Fedora Linux Support Community & Resources Center
  #1  
Old 18th June 2010, 09:54 PM
JILY0 Offline
Registered User
 
Join Date: Jun 2010
Posts: 1
windows_7ie
filename wildcards

I have three files in the directory, ABC.txt abc.txt ABC.abc.txt. When I do ls [A-Z]*[A-Z].txt, both ABC.txt and ABC.abc.txt show up. what's wrong with it?
Reply With Quote
  #2  
Old 18th June 2010, 10:32 PM
icydog Offline
Registered User
 
Join Date: Nov 2005
Posts: 451
macosfirefox
Re: filename wildcards

I would like to know the answer to this as well. I can reproduce on F13 and CentOS 5:
GNU bash, version 4.1.7(1)-release (x86_64-redhat-linux-gnu)
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)

But this works as expected OS X 10.6:
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)

(Edit: Forget I said it works on the Mac. It appeared to work because of HFS+'s weird case sensitivity rules; ABC.txt and abc.txt are the same file.)

Last edited by icydog; 19th June 2010 at 11:16 PM. Reason: wrong info about OS X
Reply With Quote
  #3  
Old 18th June 2010, 11:08 PM
smr54 Offline
Registered User
 
Join Date: Jan 2010
Posts: 7,118
linuxopera
Re: filename wildcards

AFAICT, I think you're only looking for the first two letters in the file name.
ls anything beginning with A-Z. Then, 0 or any number of characters. Then anything from A-Z. Looks to me as if it should both, unless I'm overlooking something.
Reply With Quote
  #4  
Old 18th June 2010, 11:16 PM
Dies Offline
Registered User
 
Join Date: Oct 2006
Posts: 4,758
linuxubuntufirefox
Re: filename wildcards

I don't know much about bash or regular expressions so...

But once you say [A-Z]* wouldn't that mean match everything that starts with a capital, seems like anything you put after that * wouldn't even matter since it's already matching any character any number of times.
Reply With Quote
  #5  
Old 19th June 2010, 11:15 PM
icydog Offline
Registered User
 
Join Date: Nov 2005
Posts: 451
linuxfedorafirefox
Re: filename wildcards

Quote:
Originally Posted by Dies View Post
I don't know much about bash or regular expressions so...

But once you say [A-Z]* wouldn't that mean match everything that starts with a capital, seems like anything you put after that * wouldn't even matter since it's already matching any character any number of times.
No, the stuff after the * is not ignored. For example, if you say "ls *.txt" you'd expect the stuff after * to not be ignored. (Trivia: in DOS before NT, the stuff after * on either side of the dot would get ignored, so "dir *a.txt" is the same as "dir *.txt")

--

Anyways, I found the answer. Like me, you're probably not using C sorting order. I'm using en_us.UTF-8. So it seems [A-Z] actually means [AbBcC.....zZ] which is every letter except lower case 'a'. How completely unintuitive! I've been doing it wrong all these years.

http://www.gnu.org/software/bash/man...ttern-Matching
Reply With Quote
  #6  
Old 20th June 2010, 02:18 PM
marriedto51 Offline
Registered User
 
Join Date: Jul 2009
Location: England, UK
Posts: 969
linuxfedorafirefox
Re: filename wildcards

Quote:
Originally Posted by icydog View Post
Like me, you're probably not using C sorting order. I'm using en_us.UTF-8. So it seems [A-Z] actually means [AbBcC.....zZ] which is every letter except lower case 'a'. How completely unintuitive!
Agreed!

If you want the traditional (sensible) sorting order, use
Code:
export LC_ALL=C
before using ls (or grep, or whatever else).
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LAN diskless boot - MAC wildcards possible ? live11 Servers & Networking 2 10th January 2010 09:22 PM
cp command with wildcards pshepherd Using Fedora 6 3rd January 2007 10:23 AM
mv and wildcards: cannot move `A' to a subdirectory of itself brianafischer Using Fedora 7 16th March 2006 07:14 PM
Using Wildcards with Yum - Can Ya? Can I? chris_y2k_r1 Using Fedora 8 13th March 2006 03:39 AM
Error 1: Filename must be either an absolute filename or blocklist Conquistador Installation, Upgrades and Live Media 3 4th January 2006 06:02 PM


Current GMT-time: 23:49 (Saturday, 23-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat