Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Unix Filenames help
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jamonathin




PostPosted: Sat Sep 22, 2007 10:28 am   Post subject: Unix Filenames help

Hey all,

I need to find a count all 4 letter files that start with a, s, r, t in a user-specified directory.

I can't for the life of me figure this out or find bits of help on it. What i have so far only lists the t's (from the user-specified /bin for now), but the problem is, it also includes crap like "panel-test-applets" and "test-moniker" in the count.

This is all i've been able to come up with, im not shure on how to also search for the s, r and a with that
unix:
ls -1 /bin | grep -w 't...' | wc -l
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Sat Sep 22, 2007 12:30 pm   Post subject: RE:Unix Filenames help

Can't you use '?' as a wildcard for just a single character?
jamonathin




PostPosted: Sat Sep 22, 2007 12:48 pm   Post subject: Re: Unix Filenames help

Thats what i thought at first, because thats what you can do with many other commands, but it doesn't work, and in this case, the ' . ' substitutes for the ' ? ' (took me a while to find that out). but i could probabily be wrong, using the wrong syntax
OneOffDriveByPoster




PostPosted: Sun Sep 23, 2007 9:11 am   Post subject: Re: Unix Filenames help

maybe
bash:
ls -1 /bin/[asrt]??? | wc -l
jamonathin




PostPosted: Sun Sep 23, 2007 3:08 pm   Post subject: Re: Unix Filenames help

That works perfectly, thanks a million man - and it's quite simple to understand.

+ Bits
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: