Operating System - HP-UX
1836596 Members
1691 Online
110102 Solutions
New Discussion

Re: how to search a file as non-case sensitive

 
Guna_2
Regular Advisor

how to search a file as non-case sensitive

Dear all

As every one knows the find command is case sensitive.

But if i want to search a file and that command should not sense the case. then what should i do?

Is there any switches in find command or anthing else?

Thanx & Rgds,
Guna
5 REPLIES 5
Peter Godron
Honored Contributor

Re: how to search a file as non-case sensitive

Yogeeraj_1
Honored Contributor

Re: how to search a file as non-case sensitive

hi Guna,

you may wish to pipe the output of the find to !

e.g.
find -name *.* |grep -i "search string"


hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
spex
Honored Contributor

Re: how to search a file as non-case sensitive

Hi,

The best way:
$ find /path -type f -name '[Ff][Ii][Ll][Ee][Nn][Aa][Mm][Ee]' -print

Another way:
$ find /path -type f -print | grep -i '/filename$'

PCS
James R. Ferguson
Acclaimed Contributor

Re: how to search a file as non-case sensitive

Hi Guna:

You can use Perl's Find module. For example:

# perl -MFile::Find -le 'find sub{-f && /^F\d+.*\z/is && print},"/tmp"'

In this case, we will look in the '/tmp' directory for (only) files ('-f') whose basename begins with the letter 'F', followed by one or more digits ('\d+') and zero or more characters thereafter ('.*}. The '^' and '\z' anchor this pattern so only files beginning with the letter 'F' are sought.

The 'find' is done case-insensitvely.

Regards!

...JRF...
Guna_2
Regular Advisor

Re: how to search a file as non-case sensitive

Thanks