Performance issue while using find command

Hi,

I have created a shell script for Server Log Automation Process. I have used

find xargs grep command to search the string.

for Example,

 find -name | xargs grep "816995225" > test.txt 

.

Here my problem is,

        We have lot of records and we  want to grep the string 4-5 times. so, it takes around 20 mins to finish the process.

so, how to search the string fastly using find xargs command

Please Suggest me.

Regards,
Nanthagopal A

What you posted has some problems. Since the script works correctly but slowly could you please post exactly what code you have.

Also, are you repeating the grep over the same files 3-4 times?

find /path/to/files -name '*.log'  -exec grep 'pattern'

is another way to grep files. And your xargs approach is another way as well.

Aside from posting the exact code that you are using (since what you posted isn't workable), as jim requested, also identify the operating system(s) and shell(s) on which the code will run (be specific, include version numbers).

find functionality beyond the standardized subset varies a great deal between implementations.

Regards,
Alister

Hi,

I have 4 Sub-Process. for each process i want to grep some string and finally print each sub-process results.

I have used find | xargs grep comand for grepping, the code as follows

  find . -type f ! -name "*.bz2" ! -name "*~" -name "catalina.*" | xargs grep  xxx | grep "xx\|xx\|xx\|xx" | grep "status"   

It takes 7-8 minutes for grepping the entire records in the path.

Note:

For each sub-process, i have to grep the full records. so, approximately 7*4 = 28 mins to finish the entire process. 

So, how to improve the performance.

Please Suggest me.

Regards,
Nanthagopal A

Try this

find . -type f ! -name "*.bz2" ! -name "*~" -name "catalina.*" | xargs awk '/xxx/&&/xx\|xx\|xx\|xx/&&/status/'