Operating System - HP-UX
1834483 Members
3559 Online
110067 Solutions
New Discussion

command to look thru every file on server for "8.1.6" in it

 
SOLVED
Go to solution
Ratzie
Super Advisor

command to look thru every file on server for "8.1.6" in it

What would be the proper command to look thru every file on the server and let me know when it fould 8.1.6 in it?
9 REPLIES 9
David DeWitt_2
Frequent Advisor

Re: command to look thru every file on server for "8.1.6" in it

You could probably do something like:

find / -type f -exec grep 8.1.6 {} \;

BUT, that can be somewhat intensive. If you could limit it to a set of subdirectories it would probably be better.

-dave
David DeWitt_2
Frequent Advisor

Re: command to look thru every file on server for "8.1.6" in it

My bad. There are other tweaks. You may need to use the -F option on grep to ensure it searches for a fixed string. "man grep" for details. You may also want to search for an option to search for files only of an ASCII type. Binaries don't search too well.

-dave
A. Clay Stephenson
Acclaimed Contributor

Re: command to look thru every file on server for "8.1.6" in it

You probably don't want to blindly throw grep at files without first determining if these are some sore of text files (shell scripts, Perl scripts, ascii text). Fortunately the "file" command will do that and return "text" ("ascii text", "commands text", etc.) If you fail to do this test then grep can explode.

cd to desired starting directory:

find . -type f | while read X
do
file "${X}" | grep -q -i "text"
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
grep -q '8.1.6' "${X}"
if [[ ${STAT} -eq 0 ]]
then
echo "${X}"
fi
fi
done
If it ain't broke, I can fix that.
RAC_1
Honored Contributor

Re: command to look thru every file on server for "8.1.6" in it

find . -type f 2> /dev/null|xargs file {}|grep "text"|awk '{print $1}'|awk -F : '{print $1}'|while read a;do grep -i "8.1.6" $a 2>/de/null && ll $a;done

This may kill cpu. And running it from / is a problem. also you may want to have a look at grep man page for optons like -i, -w , -w etc.

Anil
There is no substitute to HARDWORK
Biswajit Tripathy
Honored Contributor
Solution

Re: command to look thru every file on server for "8.1.6" in it

One small correction to some of the above
answers. grep for "8.1.6" string would match
"8a1b6" too as '.' means any single char.
Kind of like single char wildcard. So you might
want to grep for "8\.1\.6"

- Biswajit
:-)
lawrenzo_1
Super Advisor

Re: command to look thru every file on server for "8.1.6" in it

also you can use

find / -name "*" -exec grep -il "8.1.6" {} \;

This will search all dir's and sub dir's below / and list the files where 8.1.6 is found


HTH
hello
Peter Godron
Honored Contributor

Re: command to look thru every file on server for "8.1.6" in it

HI,
I assume you are trying to eliminate an oracle install. The official, and only supported, path is to use the installer program. Executables may have also being linked against 8.1.6 libraries, but will not show in any of the above!

Ravi_8
Honored Contributor

Re: command to look thru every file on server for "8.1.6" in it

Hi,

find / -type f -exec grep 8.1.6 {} \;
never give up
Ratzie
Super Advisor

Re: command to look thru every file on server for "8.1.6" in it

YOU NEED TO ESCAPE THE NUMBERS!

find . -type f | while read X
strings $X | egrep '8\.1\.6'
if [ $? -eq 0 ];then
echo $X >>/tmp/816.m