Operating System - HP-UX
1833044 Members
2751 Online
110049 Solutions
New Discussion

Re: fgrep: not enough memory

 
SOLVED
Go to solution
jerry1
Super Advisor

fgrep: not enough memory

I know what your thinking.

This system is: Model:9000/800/S16K-A
24448 megabytes

I am doing a global find with fgrep.
Excluding NFS mounts of course.

Why is fgrep barking. Is it some kind of buffer
limitation, kernel parm, etc...??




5 REPLIES 5
Jeff Schussele
Honored Contributor
Solution

Re: fgrep: not enough memory

Hi Jerry,

Several things:

1)Does grep -F ...... do the same thing? fgrep is obsolete now.
2) swap reservation exceeded?
swapinfo -tam
3) max?siz kernel parm maxxed out?
4) ulimit?

If you're grepping the entire system via find, then I'd suspect #3 or #4 is your problem.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
A. Clay Stephenson
Acclaimed Contributor

Re: fgrep: not enough memory

I suspect that you are grepping on a non-text file so that unexpected behavior is encounter. You probably should put a 'file' command in and text to see if this is an ASCII file before grepping.
If it ain't broke, I can fix that.
Elmar P. Kolkman
Honored Contributor

Re: fgrep: not enough memory

Have you tried the fgrep command on a single file, to see if your problem is with fgrep or the specific file?

The '-type f' in the commandline for the find command might help if the fgrep line works on normal files.

If not, you might make a script that calls fgrep after logging the file it runs on to see what file is causing fgrep to fail...
Every problem has at least one solution. Only some solutions are harder to find.
jerry1
Super Advisor

Re: fgrep: not enough memory

Here is the script. OS is HP-UX 11.11

#!/bin/ksh

find / -fsonly hfs -fsonly vxfs -type f -exec fgrep -l "128.166." {} \;>$1.ip

strings=`cat ./exclude.strings`

cat $1.ip|egrep -i -v "$strings">$1.ip.1

----------------------------------------

maxdsiz 131072 - 0-503866 Pages -
maxdsiz_64bit 262144 - 1024-1073479679 Pages
maxssiz 16384 - 0-98048 Pages -
maxssiz_64bit 2048 - 4-262144 Pages -
maxtsiz 65536 - 0-503859 Pages -
maxtsiz_64bit 262144 - 1024-1073741823 Pages

A. Clay Stephenson
Acclaimed Contributor

Re: fgrep: not enough memory

As I tried to explain yesterday, you need to check to see if you are grepping a text file. Grepping a binary file (e.g. an executable) will yield absolutely chaotic results -- including program crashes. A -f find test is a necessary but not sufficient test. It determines that the file is a regular file but it does not determine that the file is a text file -- the file command does that.


You need to do something like this:

find / -fsonly hfs -fsonly vxfs -type f -exec ftest.sh {} \;>$1.ip

Now ftest.sh looks like this:
#!/usr/bin/sh

FNAME=${1}
file ${FNAME} | grep -q "text"
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
fgrep -l "128.166." ${FNAME}
fi
exit 0

This code could be made more efficient via xargs but that is left as an exercise for the reader.


If it ain't broke, I can fix that.