1834202 Members
3630 Online
110066 Solutions
New Discussion

find command

 
SOLVED
Go to solution
Shivkumar
Super Advisor

find command

Is it possible to give case insensitive option while searching files using hpux find command ?

Thanks,
Shiv
8 REPLIES 8
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: find command

Not precisely but this sort of thing is possible:

find . -name '[xX]*[cC]' -print
which would match
x.c
x.C
X2.c
X4567.c

among others.
If it ain't broke, I can fix that.
baiju_3
Esteemed Contributor

Re: find command

What is the file pattern you need to search .

you can use the below regular expression to print 2 files test and Test .

find . -name "[tT]est" -name .

thx,
bl.
Good things Just Got better (Plz,not stolen from advertisement -:) )
Rodney Hills
Honored Contributor

Re: find command

If you use the gnu find utility. It is available from the HP software porting and archive centre.

http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.2.20/

HTH

-- Rod Hills
There be dragons...
Arunvijai_4
Honored Contributor

Re: find command

Shiv,

From the man pages:
grep:
-i, --ignore-case
Ignore case distinctions in both the PATTERN and the input files.

find:
-ilname pattern
Like -lname, but the match is case insensitive.

-iname pattern
Like -name, but the match is case insensitive. For
example, the patterns `fo*' and `F??' match the file
names `Foo', `FOO', `foo', `fOo', etc.

-ipath pattern
Like -path, but the match is case insensitive.

-iregex pattern
Like -regex, but the match is case insensitive.
"A ship in the harbor is safe, but that is not what ships are built for"
Cem Tugrul
Esteemed Contributor

Re: find command

Shiv,

Let's say you want to find out files like
TEST or test so;

find . -name "[tT]est" -exec ll -d { } \;

Good Luck,
Our greatest duty in this life is to help others. And please, if you can't
Muthukumar_5
Honored Contributor

Re: find command

find command is using only pattern matching not regexp's. You have to use pattern matches with -name option as,

file1
File1

find . -name "[Ff]ile?"

[Ff] - selection list whether F of f

? - any character

You can use grep -i to ignore case.

hth.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: find command

Send your exact requirement to give suitable REGEXP with find. find + grep will give bad performance.

You can use find + xargs + grep instead of find + -exec as,

find / -name "*" | xargs grep -i ""

hth.
Easy to suggest when don't know about the problem!
Vibhor Kumar Agarwal
Esteemed Contributor

Re: find command

You can use a mixture of find and grep for that:

find . -type f | grep -i name

-i option of grep will be case-insensitive.
Vibhor Kumar Agarwal