Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using find for filename searching

Status
Not open for further replies.

eustathi

Technical User
May 9, 2007
9
GR
Hello guys

I am using this , it will print all the files which the final character in each name is e right?
It will also contain files with .e extension?

Code:
find . -name '*[a-zA-Z0-9][e]' -print

Look my test
./ddd.sh.save
./c1.exe
./.gconf/desktop/gnome
./.gconfd/saved_state
it didn't include a file test.e why? any helpful link?

THANKS!!!!!
 
it didn't include a file test.e why?
Because . don't match [a-zA-Z0-9]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
What I meant is that the . (dot) is not part of the [a-zA-Z0-9] character class and thus, test.e is not matched by *[a-zA-Z0-9][e]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Because x is matched by [a-zA-Z0-9]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
in your pattern '*[a-zA-Z0-9][e]' you specify that the last character of the filename must be an 'e' and the character just before must be a upeer or lowercase letter or a digit

so:
c1.exe matches - last=e OK char_before=x=lowercase letter OK
test.e does not match - last=e OK char_before=. NOT letter or digit NOK

In UNIX the dot is part of the filename and you can have more than one dot in a filename (more than one filename extension).


HTH,

p5wizard
 
How about
Code:
find . -name '*e' -print
???
Test in my Ubuntu-Bash:

find . -name '*e' -print
./ddd.sh.save
./c1.exe
./.gconf/desktop/gnome
./.gconfd/saved_state
./test.e

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top