Errror string catch: redundancy with grep command

Currently I am using the following command to catch the Error String in the MY_FILE_NAME*.log

Currentdate=`date -u +"%Y/%m/%d"`
YEST=`TZ=XYZ+24 date '+%Y/%m/%d'`

grep -E "$Currentdate|$YEST"  MY_FILE_NAME*.log |  grep "Type: Error"

This command is generating huge data with the string "Type: Error" with redundancy in the same error type (in my case the same error is displayed like 100 times)

I want the error strings of same type to be displayed only once

Answers


If using GNU/Linux try the '-m' switch

grep -m 1 -E "$Currentdate|$YEST"  MY_FILE_NAME*.log |  grep "Type: Error"

In the GNU version of grep, the '-m ' switch stops reading the input file after matches are found. This feature does not exist in the older Unix grep on which AIX and similar are built.

If on AIX where there is no -m or -B see this StackOvreflow post


Need Your Help

Selenium RC sending blank screenshots through (winxp/winserver)

php selenium screenshot selenium-rc

I'm trying to set up my virtual (xen) win xp instances, a dedicated windows server, and a dedicated windows xp desktop pc for web app UI testing, using selenium-rc and the selenium PHP API from pea...