- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- searching a file with ignore case option; find com...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 05:56 AM
тАО01-26-2006 05:56 AM
I usually use the command to search a file say BigGuy.txt, "$find / -name BigGuy.* -print".
My question is, sometime i don't know whether a file has uppercase letters in it.
If i want to use ignore case option while searching a file then what command/option do i need to use ?
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 06:02 AM
тАО01-26-2006 06:02 AM
Re: searching a file with ignore case option; find command
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 06:17 AM
тАО01-26-2006 06:17 AM
Re: searching a file with ignore case option; find command
for details of regular exp .
man 5 regexp .
Regards ..bl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 06:33 AM
тАО01-26-2006 06:33 AM
Re: searching a file with ignore case option; find command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 06:37 AM
тАО01-26-2006 06:37 AM
Re: searching a file with ignore case option; find command
If your .txt will remain constant,
then,
use
find / -name *.txt -print |grep -i bigguy
Cheers.
Chan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 06:58 AM
тАО01-26-2006 06:58 AM
Solution# cat ./finder
#!/usr/bin/perl -l
#@(#)finder finder $ Find files by name case-insensitively - JRF $
use strict;
use warnings;
use File::Find ( );
use vars qw( *name );
use Cwd;
die "Usage $0 [directory ...] file\n" unless @ARGV;
my $regex = pop;
@ARGV = cwd unless @ARGV;
*name = *File::Find::name;
sub wanted {
return unless m/^$regex\z/is;
print $name;
} # wanted
File::Find::find( \&wanted, @ARGV );
1;
#_(jrf)
Run like this (pass the directory and the file name as two arguments:
# ./finder /var SySlOg.LoG
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 09:09 AM
тАО01-26-2006 09:09 AM
Re: searching a file with ignore case option; find command
Here's an improved version of the above (attached). It removes the anchoring of the matched token to matching exactly the basename.
If you use regular expressions as your filename argument, surround them with sigle quotes so that the shell doesn't try to interprest them.
You can do things like:
# ./finder /tmp 'perl.+\.depot'
...which might return:
/tmp/perl_D.5.8.2.A_HP-UX_B.11.11_32+64.depot
# .finder /var SySlOg
...which might return:
/var/adm/syslog
/var/adm/syslog/syslog.log
/var/adm/syslog/OLDsyslog.log
/var/run/syslog.pid
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 02:53 PM
тАО01-26-2006 02:53 PM
Re: searching a file with ignore case option; find command
If you are working on Linux, try using "locate" command. Its very easy to use and gives good result.
http://www.computerhope.com/unix/ulocate.htm
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 04:43 PM
тАО01-26-2006 04:43 PM
Re: searching a file with ignore case option; find command
Here is a short script I just wrote. It appears to solve our problem.
The case you type the filename in does not matter. The script generates the reg exp for you.
You could name this script find and put it in a dir that comes before the real find(/bin/find) in your PATH.
#!/bin/ksh
FINDME=$2
LEN=`echo ${FINDME} | wc -c`
CHAR_CNT=1
NAME=""
while true
do
CHAR=`echo ${FINDME} | cut -c ${CHAR_CNT}`
UPPER=`echo $CHAR | tr "[:lower:]" "[:upper:]"`
LOWER=`echo $CHAR | tr "[:upper:]" "[:lower:]"`
if [[ $CHAR = [A-Za-z] ]];then
NAME=${NAME}"[${UPPER}${LOWER}]"
else
NAME=${NAME}"${CHAR}"
fi
CHAR_CNT=`echo "$CHAR_CNT + 1"|bc`
if [[ $CHAR_CNT -eq LEN ]]
then
break
fi
done
echo find $1 -name "$NAME" $3 $4 $5 $6 $7 $8 $9
find $1 -name "$NAME" $3 $4 $5 $6 $7 $8 $9
OUTPUT:
Short:
./Find /tmp SEND*
find /tmp -name [Ss][Ee][Nn][Dd]*
/tmp/sendchkdb
/tmp/send.ndm
/tmp/send.WB
/tmp/send.33
/tmp/send.28
Long:
./Find /tmp SEND* -exec ll -adl {} \;
find /tmp -name [Ss][Ee][Nn][Dd]* -exec ll -adl {} ;
-rwxr-xr-x 1 root sys 229 Dec 2 2004 /tmp/sendchkdb
-rwxrwxrwx 1 root sys 474 Jan 26 13:28 /tmp/send.ndm
-rwxrwxrwx 1 root sys 933 May 20 2004 /tmp/send.WB
-rwxrwxrwx 1 root sys 933 May 20 2004 /tmp/send.33
-rwxrwxrwx 1 root sys 933 May 20 2004 /tmp/send.28
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 04:56 PM
тАО01-26-2006 04:56 PM
Re: searching a file with ignore case option; find command
another easy way would be to do a normal find and grep the output ignoring the case.
e.g.
$ find . -print |grep -i bigguy
./test/BigGuy
$ touch test/bIggUy
$ find . -print |grep -i bigguy
./test/BigGuy
./test/bIggUy
$
this of course would be applicable to file systems with relatively limnited number of files.
hope this helps too!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 04:56 PM
тАО01-26-2006 04:56 PM
Re: searching a file with ignore case option; find command
$ find / -name "*" -type f | grep -i bigguy
It will help. Else you have to try as,
$ find / -name "[Bb][iI][gG][gG][uU][Yy].*" -type f -print
Note: Try to use -type f option with find always.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-26-2006 05:00 PM
тАО01-26-2006 05:00 PM
Re: searching a file with ignore case option; find command
You can even try this,
# find / -type f |grep -i "bigguy"
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-03-2006 07:27 AM
тАО02-03-2006 07:27 AM
Re: searching a file with ignore case option; find command
GNU find has an -iname/-ipath/-iregex/-i