Mysql log has something like:
I want to grep only the portion "ernie-1328697839.1233158" from each line. How to do this?
Mysql log has something like:
I want to grep only the portion "ernie-1328697839.1233158" from each line. How to do this?
Suppose you have the log ina file called "file", here's the code you want to execute:
awk -F "'" '{ print $2 }' file | awk -F "-%" '{ print $1 }'
Now i want a script that will scan the mysql.log file and if it finds 5 consecutive instances of the same line then it would execute certain commands.
if [ `sed "s/.*\(ernie-1328697839.1233158\).*/\1/" mysql.log | wc -l` -ge 5 ]; then echo yes; fi
To be more precise:
1) The script will scan the mysql.log file in real time(something like tail -F mysql.log)
2) If it encounters 5 consecutive identical lines then it would invoke some commands.
Any help will be highly appreciated.
1) Extremely sorry for that.
2) How? Can you help with the basic logic.