1833238 Members
2754 Online
110051 Solutions
New Discussion

Re: find files

 
SOLVED
Go to solution
j773303
Super Advisor

find files

Does anyone knows how to find files as below? Which options can be apply in find ? Thanks.

#find . -name test.txt

It can be found "test.txt" or "TEST.txt" or "TEST.TXT" or "test.TXT"

Hero
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: find files

Use the find -o (or operator)

find . -name \( -name 'test.txt' -o -name 'TEST.txt' -o -name 'test.TXT' \)

Plan B. Find everything and then use a case insensitive grep as a filter:

find . -type f -print | grep -i 'test.txt'
If it ain't broke, I can fix that.
Sridhar Bhaskarla
Honored Contributor

Re: find files

Hi,

One 'confusing' way is to use expression like this

find . -name \[Tt\]\[Ee\]\[sS\]\[tT\]\.\[tT\]\[xX\]\[tT\]


-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Hein van den Heuvel
Honored Contributor

Re: find files


I know you can do wildcards ("*" or "?") but I do not think you can do case sensitivity.

Of course you can do 'or conditions', but that's tedious...

find . -name test.txt -o -name TEST.txt -o -name TEST.TXT -o -name test.TXT


Hein.
Sridhar Bhaskarla
Honored Contributor

Re: find files

The expression given by me works for me.

The '-o' option is an easy way for file names of shorter length. However, as the number of letters in the filename increase, the combinations will increase and it can become unmanageable. [] notation may confuse a little bit but it doesn't really increase your command line.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Michael D'Aulerio
Regular Advisor

Re: find files

I use grep:
find . | grep -i test.txt

Mike D'.
Email: michael.n.daulerio@lmco.com
Rodney Hills
Honored Contributor

Re: find files

You could get the gnu find from HP porting and archive site. It has an option "-iname" that does case insensitive matches.

HTH

-- Rod Hills
There be dragons...
H.Merijn Brand (procura
Honored Contributor

Re: find files

# find . | fgrep -i -w test.txt

# perl -MFile::Find -le'find(sub{lc$_ eq"test.txt"and print$File::Find::name},".")'

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn