I have a large log file, which I want to first use grep to get the specific lines then send it to awk to print out the specific column and if the result is zero, don't do anything. What I have so far is:
LOGDIR=/usr/local/oracle/Transcription/log
ERRDIR=/home/edixftp/errors
#I want to be able to count the lines of the result
cnt255=exec grep FAILED $LOGDIR/processor.log | grep `date +20%y%m%d%y` | grep 255 | wc -l
#$cnt255 is 0
if I run
grep FAILED $LOGDIR/processor.log | grep `date +20%y%m%d%y` | grep 255
I get,
Thu Nov 15 05:42:15 PST 2007: FAILED TO PROCESS FILE 20711150790576400.TXT - exit_code=255
[/code]
I want to run an if statement that says if $cnt255 > 0 then process the grep statement and send the result to a file.
How can I send the count of the grep->awk to the variable $cnt255?
I am new to UNIX scripting.
TIA
Mike