Operating System - HP-UX
1752792 Members
6410 Online
108789 Solutions
New Discussion юеВ

Re: find command causes dump?

 
Dag A.
Frequent Advisor

find command causes dump?

I tried the following command to find log files with the text 'ERR' in them:

>find . -name '*.log' |xargs grep ERR

This works fine. But when i look for files containing 'err', this happens:

>find . -name '*.log' |xargs grep err
find: cannot open ./.Thatfile
THE APPLICATION PROGRAM DUMP DUMP SUCCESSFULLY CREATED!
THE APPLICATION PROGRAM DUMP DUMP SUCCESSFULLY CREATED!

and so on

Apparently, the last command should have been
>find . -name '*.log' |xargs grep 'err'
instead

Any idea what happened here?
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: find command causes dump?

You shouldn't have to quote "err" in the grep.
If you can't figure out how to use xargs, give up and pass xargs a simple script:
$ find . -name '*.log' | xargs grep_err

Then create a script called grep_err:
#!/usr/bin/ksh
grep err $@
Rasheed Tamton
Honored Contributor

Re: find command causes dump?

I agree with Dennis. No need to quote err with the grep.

May be your OS version is bit old or not patched well.

You can also try
find . -name '*log' -exec grep err {} \;

or
find . -name '*list*' -exec grep err {} +
Peter Nikitka
Honored Contributor

Re: find command causes dump?

Hi,

first check, if 'grep' really results in what all expect:
type grep
This should be /usr/bin/grep .

Two more thoughts:
1) Feed only plain files to grep - your find command lists even dirs, FIFOs, ...
find . -type f -name '*.log' |xargs grep err

2) grep won't tell the filename, when only one argument is supplied. This may happen, when there is only one file found or just one left for the last call of xargs. I suggest to provide /dev/null for this:
find . -type f -name '*.log' |xargs grep err
/dev/null

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Dag A.
Frequent Advisor

Re: find command causes dump?

Closing thread.

By the way, the OS is old (ver 10.20)