Computer Science Canada

Unix Filenames help

Author:  jamonathin [ 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

Author:  Mazer [ 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?

Author:  jamonathin [ 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

Author:  OneOffDriveByPoster [ Sun Sep 23, 2007 9:11 am ]
Post subject:  Re: Unix Filenames help

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

Author:  jamonathin [ 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


: