I need to have a process (mailx alert) scheduled frequnetly
My requirement is to grep a specific file for a specific word.
If the word is found send me an alert.
However if the word was also found the previous run do not send the mail(kind of reset mechanism for the alert)
GREP FILE for the word ABENDED
IF word ABENDED found
THEN
IF FLAG EXIST
THEN EXIT
ELSE MAIL USER, TOUCH FLAG
ELSE EXIT
My main idea is above however not completed.
Can you please provide sample code?
bash-3.00$ cat test
a
b
c
d
e
f
g
h
bash-3.00$ nawk '/c/{val=NR} END{print val}' test
3
bash-3.00$ echo "c" >> test
bash-3.00$ !nawk
nawk '/c/{val=NR} END{print val}' test
9
bash-3.00$ cat -n test
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 h
9 c