perform a check based on number of @ in a log line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perform a check based on number of @ in a log line
# 8  
Old 02-26-2009
Code:
awk -F"@" '{print FNR, NF, $0}' myFile

# 9  
Old 02-26-2009
awk -F"@" '{print FNR, NF, $0}' /root/testlog | grep fixed_login


gives me desired result, like:

72 ( is the count of @ )



72 2009-02-20 11:20:10 [16806] 1LaZ2i-0004N4-0H <= mariana@sumergibawew.tld H=([z.z.z1.46]) [189.x.x.x]:49181 I=[y.y.y.12]:26 P=esmtpa A=fixed_login:mariana@sumergibawew.tld S=57438 id=C5C44259.BF4%mariana@sumergibawew.tld T="ESTUCHES Y LINTERNAS PELICAN PROMOCION DEL MES" from <mariana@sumergibawew.tld> for conpras@lumen.tld ednoriega@intelcompras.tldx eduardo@smartsonicsupply.tldx gabrielm@grupoatr.tldx juliowitrago@testmail.tldx gustavoescarcega@asdasdasdastld dmecanico@fabatsa.tld apca50@testmail.tldx coloresyaditivos@axtel.net jlmerodio@testmail.tldx recepcion_mexico@globaldrilling.tld jsandoval@pinnocle-home.tld felix.gonzalez@adsmexicana.tldx aygservicios_especializados@asdasdasdastld desisti@desistimexico.tldx marecidive@testmail.tldx beto.garcia3@xailasasa.tldx egarcia@crockettint.tldx mangel@mexichen.tldx browningmexico@asdasdasdastld jmenab@mebaimportaciones.tld lisandoval@xailasasa.tldx disi_ventas@asdasdasdastld cturati@turavision.tld erikpalme@testmail.tldx daniela_salinas@testmail.tldx bom_alfonso@testmail.tldx charliees@asdasdasdastldx greg_vo@asdasdasdasit alberto.anguino.aa@lanxess.tldx emoreno@codeciphers.co.uk info@mundosubmarino.tld jrodriguez@sipsamex.tldx ernesto.matias@cfe.gob.mx ruly_benhur@testmail.tldx israelguerrero@asdasdasdastld ftorres@geolect.tld mariana@sumergibawew.tld freddypv35@xailasasa.tldx ramces.villanueva@vro.tld tropa212003@asdasdasdastldx eduardo.lopez@grainger.tldx contreras@defensa.tld jesus.gonzalez@admexicana.tldx compras@vro.tld fullservice@ndt.tld laurahinojosa2003@asdasdasdastld oscar.mar@psi-ind.tld colin_arturo@testmail.tldx rolmale@gamail.tldx juan.iskander@xailasasa.tldx mzlopezm@deacero.tldx raul@serecom.tld alejandrordz73@testmail.tldx victormr@ilsamexico.tldx gbriones@wittman.tld bksystem2@asdasdasdastld guisami@testmail.tldx aicsageo@testmail.tldx ozzflores@maill.risoul.tld fision_energias@infosel.net.mx medina.torres@asdasdasdastldx cds@ver.megared.net.mx loose@prodigy.net.mx cbprovento@asdasdasdastld cbravosdc@prodigy.net.mx stovar@meyersound.tld




Now, I want something like,




awk -F"@" '{print FNR, NF, $0}' /root/testlog | grep fixed_login


the first colum gives the number of @.


Now, we want a code that will check each of the line for ( awk -F"@" '{print FNR, NF, $0}' /root/testlog | grep fixed_login | awk {'print $1}' ) and if the value for any one line is > 30 , it should declare that line a mass emailer and alert the line number or append all the lines, that has more than 30 "@" to and file and email it to a particular address.

Any ideas appreciated
# 10  
Old 02-26-2009
Code:
awk -F"@" '/fixed_login/ && NF > 30 {print FNR, NF, $0}' /root/testlog

# 11  
Old 02-26-2009
ok that wondeful, vgersh99

Now, what i want run a cron , that will check the log file for last 60 mings of of logs generated in the log file , every 5 min, for the above command and if it finds one it will email.

Any idea on how can we can most recent 60 mins of generated logs, every 5 mins.


Thanks
# 12  
Old 02-26-2009
Quote:
Originally Posted by fed.linuxgossip
ok that wondeful, vgersh99

Now, what i want run a cron , that will check the log file for last 60 mings of of logs generated in the log file , every 5 min, for the above command and if it finds one it will email.

Any idea on how can we can most recent 60 mins of generated logs,
man find
Quote:
Originally Posted by fed.linuxgossip
every 5 mins.
man crontab
# 13  
Old 02-26-2009
thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To check the missing file based on sequence number.

Hi All, I have a requirement that i need to list only the missing sequences with a unix script. For Example: Input: FILE_001.txt FILE_002.txt FILE_005.txt FILE_006.txt FILE_008.txt FILE_009.txt FILE_010.txt FILE_014.txt Output: FILE_003.txt FILE_004.txt FILE_007.txt FILE_011.txt... (5 Replies)
Discussion started by: Arun1992
5 Replies

2. Shell Programming and Scripting

How to split a file based on pattern line number?

Hi i have requirement like below M <form_name> sdasadasdMklkM D ...... D ..... M form_name> sdasadasdMklkM D ...... D ..... D ...... D ..... M form_name> sdasadasdMklkM D ...... M form_name> sdasadasdMklkM i want split file based on line number by finding... (10 Replies)
Discussion started by: bhaskar v
10 Replies

3. Shell Programming and Scripting

How to check the number of columns in a line??

hi, i have a file with many records and each record may or may not have 6 columns. for example file1 : first second third fourth fifth sixth first second third fourth fifth first second third fourth fifth sixth first second third fourth fifth sixth seventh eigth if i cat the file and... (21 Replies)
Discussion started by: Little
21 Replies

4. Shell Programming and Scripting

Splitting a file based on line number

Hi I have a file with over a million lines (rows) and I want to split everything from 500,000 to a million into another file (to make the file smaller). Is there a simple command for this? Thank you Phil (4 Replies)
Discussion started by: phil_heath
4 Replies

5. Shell Programming and Scripting

[Solved] How to separate one line to mutiple line based on certain number of characters?

hi Gurus, I need separate a file which is one huge line to multiple lines based on certain number of charactors. for example: abcdefghi high abaddffdd I want to separate the line to multiple lines for every 4 charactors. the result should be abcd efgh i hi gh a badd ffdd Thanks in... (5 Replies)
Discussion started by: ken6503
5 Replies

6. Shell Programming and Scripting

Line number based manipulation

Hi I have a case where I am grabbing patterns and subsequent lines using sed -n -e '/regex/{$!N;p;}' This returns just the regex line when it is the last line of my file. Now I may have even number of lines in some cases (regex never at end) and odd in very rare cases. If the line... (6 Replies)
Discussion started by: jamie_123
6 Replies

7. Shell Programming and Scripting

Delete lines based on line number

I have a file with ~200K lines, I need to delete 4K lines in it. There is no range. I do have the line numbers of the lines which I want to be deleted. I did tried using > cat del.lines sed '510d;12d;219d;......;3999d' file > source del.lines Word too long. I even tried... (2 Replies)
Discussion started by: novice_man
2 Replies

8. Shell Programming and Scripting

How to perform action on newest line in log using tail?

I don't quite know what I'm doing, so this simple script is proving a challenge. Here is some pseudo code that doesn't work yet: if tail -1 "WORKING.txt" >/dev/null | egrep "^NMBR=*" > /dev/null then curl -k 'http://www.myserver.com/log.cgi?input=$?' echo "hi there" fi Purpose:... (3 Replies)
Discussion started by: dihewidd
3 Replies

9. Shell Programming and Scripting

Print selection of line based on line number

Hi Unix gurus Basically i am searching for the pattern and getting the line numbers of the grepped pattern. I am trying to print the series of lines from 7 lines before the grepped line number to the grepped line number. I am trying to use the following code. but it is not working. cat... (3 Replies)
Discussion started by: mohanm
3 Replies

10. Shell Programming and Scripting

extracting a line based on line number

i want to cut all the entries from the /etc/passwd file in which the uid is> 500 for this i was writing this ,m quiet new to all this.. scripting but on the 6th n 8th line ,, i hav to specify a line number .. to get the commnd working .. but i want to use variable i instead of that ,,... (2 Replies)
Discussion started by: narendra.pant
2 Replies
Login or Register to Ask a Question