Operating System - HP-UX
1830136 Members
2441 Online
109999 Solutions
New Discussion

HP-UX 10.20 finding pattern.!!

 
SOLVED
Go to solution
Raj D.
Honored Contributor

HP-UX 10.20 finding pattern.!!

Hi all ,

How do i do recursive grep , for a pattern in HP-UX 10.20 .

I want to search the string "80.0.0.10" in all the files from root.

Please help me .

Raj. D
-------
" If u think u can , If u think u cannot , - You are always Right . "
7 REPLIES 7
Thierry Poels_1
Honored Contributor

Re: HP-UX 10.20 finding pattern.!!

hi,

find / -type f -exec grep -l "80.0.0.10" {} \;

but be aware of high system load.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Franky_1
Respected Contributor

Re: HP-UX 10.20 finding pattern.!!

Hi Raj,

simply type

cd /
for i in `ls`
do
grep -l '80.0.0.10' $i
done

Simple and fast :-)

Franky
Don't worry be happy
Petr Simik_1
Valued Contributor

Re: HP-UX 10.20 finding pattern.!!

As Thierry wrote:
I suggest to use find and define/specify name of files. Otherwise it will take too long time to look inside all files. It is usuallu ascii/conf files.

find / -name "file*.*" -type f -exec grep -l "80.0.0.10" {} \;



Muthukumar_5
Honored Contributor

Re: HP-UX 10.20 finding pattern.!!

You can do it as ,

grep '90.0.0.10' `find -name "*"`

If you are going to search in all files, there will be some problem.

grep will make problem on searching a patter in an object executable files.

It is good to use some extensions of a file.

Example:
grep '80.0.0.10' `find . -name "*.log"`
./test.log:80.0.0.10

-- muthu --

Easy to suggest when don't know about the problem!
Franky_1
Respected Contributor

Re: HP-UX 10.20 finding pattern.!!

Hi,

my proposal is fast if it's in the straight line - otherwise you'll have to use the `ls -R` option which takes longer time.
If you want to use the "find" - option then you can limit the search through the use of "-xdev" (without crossing mount points) which would speed up the search

find / -xdev -type f -exec ...

Franky
Don't worry be happy
Raj D.
Honored Contributor

Re: HP-UX 10.20 finding pattern.!!

Thanks Therrie , Franky , Muthukumar and all who replied.

Well it is taking lond time , is there any way to find out the string "80.0.0.10" , for ASCII files only.

i wanted to know which files in oracle is using the IP address , or hostname .

ASCII file searching only would be a good options. And feedback will be appreciated.

Raj .D
-------
" If u think u can , If u think u cannot , - You are always Right . "
Franky_1
Respected Contributor
Solution

Re: HP-UX 10.20 finding pattern.!!

Hi,

as a workaround you can try the following :

for i in `ls -R`
do
file $i|grep ascii
if test $? = 0
then
grep -l '80.0.0.10' $i
fi
done

Regards

Franky
Don't worry be happy