|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Mysql log has something like below:
Quote:
1) The script will scan the mysql.log file constantly in real time (something like tail -F mysql.log) 2) If it encounters 5 consecutive identical lines then it would invoke some commands (say echo "yes") Please help. Last edited by proactiveaditya; 02-09-2012 at 07:53 AM.. |
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
This appears to be a continuation of:
http://www.unix.com/shell-programmin...ignP=302596963 What does "tail -F" do on your Operating System? Not valid on mine. What Operating System and version do you have? In general it is a major programming exercise to "tail -f" a file and carry out any further processing in a pipeline. There have been posts on this board which suggest using named pipes. |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
tail -F is same as tail -f --retry Code:
man tail
--retry
keep trying to open a file even if it is inaccessible when tail starts or if it becomes inaccessible later; useful when following by name, i.e., with --follow=nameAvailable on GNU/Linux |
|
#4
|
||||
|
||||
|
If you are using GNU/Linux checkout fflush() in gawk: Code:
tail -F infile | awk 'function ff(){ if(A[p]>4) {print "yes - " p; fflush() ; A[p]=0 } } {ff(); A[$0]++} $0!=p{p=$0} END{ff()}'*edit* Actually, this should suffice, since the END section will never happen: Code:
tail -f infile | awk 'A[p]>4{print "yes - " p; fflush(); A[p]=0} $0!=p{p=$0} {A[p]++}'Last edited by Scrutinizer; 02-09-2012 at 01:30 PM.. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
What about:
Quote:
|
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing consecutive lines in a file | deneuve01 | Shell Programming and Scripting | 11 | 10-06-2011 02:31 PM |
| finding and removing 2 identical consecutive words in a text | cocostaec | Shell Programming and Scripting | 11 | 05-01-2011 10:53 PM |
| how to delete two consecutive lines from the file | aoussenko | Shell Programming and Scripting | 5 | 04-12-2011 02:34 PM |
| Find time difference between two consecutive lines in same file. | vilibit | Shell Programming and Scripting | 6 | 03-14-2011 06:16 AM |
| Cutting n consecutive lines from a file... | Vishnu | UNIX for Dummies Questions & Answers | 2 | 10-18-2002 10:49 AM |
|
|