Sponsored Content
Full Discussion: syslog grep/awk/sed display
Top Forums Shell Programming and Scripting syslog grep/awk/sed display Post 302438340 by Ikon on Monday 19th of July 2010 11:12:58 AM
Old 07-19-2010
syslog grep/awk/sed display

What i am trying to do is pull all the "fail" and "error" from the HP-UX syslog except if it includes "sshd" or "ftpd" and IF the next line says "above message repeats NN time" display the next line.


Got some of it working with someones help with sed but Im more familiare with awk.

Trying to do this with awk:

Code:
cat syslog.log | sed -e '/sshd/d' -e '/ftpd/d' -e '/error/b' -e '/fail/b' -e d

I can do half:

Code:
awk '/(error|fail)/ { print; }' syslog.log

I want to add the !/(sshd|ftpd)/ to the awk statement in one statement, if possible.

Then I want to display the next line IF next line contains " above message repeats NN times"

I know how to display next next line:
Code:
awk '/(error|fail)/ { print; getline; print; }' syslog.log

But not sure how to do it ONLY if it contains " above message repeats NN times" and include the !/(sshd|ftpd)/

I know I can do it with multiple greps but I would like an awk one liner.

Last edited by Scott; 07-19-2010 at 12:16 PM.. Reason: Code tags...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need help!!!awk,grep,sed

hi all by using cat /etc/passwd I've got these output. ajh1ect:x:839:501:Anthony:/home/ajh1ect:/bin/bash mjb1ect:x:840:501:Michael:/home/mjb1ect:/bin/bash mv3ect:x:841:501:Marian:/home/mv3ect:/bin/bash now I want to see just the user ID and group ID. so what is the code will be with... (2 Replies)
Discussion started by: nokia1100
2 Replies

2. Shell Programming and Scripting

Sed | Awk | Grep

Can someone help me in understanding when to use SED, AWK and GREP (3 Replies)
Discussion started by: kn.naresh
3 Replies

3. UNIX for Dummies Questions & Answers

Awk, Sed and Grep

Hello. I am an older newbie trying to learn Unix. I have a task to perform and it entails counting lines of code. Currently, I am pointing to the directory where the files are contained and performing a 'find' on the file extensions (cpp, c, html, java, etc.) and piping that info with a 'wc -l'.... (2 Replies)
Discussion started by: mastachef
2 Replies

4. UNIX for Dummies Questions & Answers

Grep Sed or Awk?

I have two .txt files one called good.txt and the other one is called bad.txt. Both contain email addresses in the following format: john@john.com bob@bob.com sarah@sarah.com Basically, I want to scrub good.txt against bad.txt and save the resulting output in scrubbed.txt meaning that if... (2 Replies)
Discussion started by: holyearth
2 Replies

5. UNIX for Dummies Questions & Answers

How could i get this by sed or grep or awk ????

------------------------------------------------------------------ Ex of Warning messgae,(Many similar lines occure for Both Test and Test1) -WARNING:Below Field not implemented in file File name: /home/test/ new/file1, msg buffer is: :Test:000948 ... (1 Reply)
Discussion started by: prsam
1 Replies

6. UNIX for Dummies Questions & Answers

awk grep sed or something better

Hello all, Can anyone help with the following? :) I have file1 with 150,000 words in a list and file2 with 148,000 words in a list - all of which are in file1. I want to create a new file with the words that DO NOT match (i.e of 2000 words). I have done this very simple command , which is... (1 Reply)
Discussion started by: dr_sabz
1 Replies

7. UNIX for Dummies Questions & Answers

grep/awk/sed?

Thread1 { x = 2 y = 10485 } Thread2 { x = 16 y = 1048 } Thread3 { x = 1 y = 1049 } Thread4 { x = 4 y = 1047 z = 500 } Suppose the above is a piece of code. I need to automate and verify that the value of x under Thread1's 2. There are several... (3 Replies)
Discussion started by: foxtron
3 Replies

8. Shell Programming and Scripting

Display output as columns using grep/awk/sed

I have several files with say something like cat sparrow I can grep for "cat" and "sparrow" and usually the output is one below the other cat sparrow How can I view these as columns say Pets Birds cat sparrow Would be great if this can be on command line using awk or... (1 Reply)
Discussion started by: gubbu
1 Replies

9. Shell Programming and Scripting

Grep awk sed display value

Hello all, I wget a file and i tried to display some value : content=$(wget IP:9005/GlobalStatistics -q -O -) echo onlineusers $content > /home/active_session_log #cat active_session_log {"ActiveSessionCount":0,"ActiveGameCount":0,"QueueMatchMakingPlayerCount":0} My goal is write... (7 Replies)
Discussion started by: acidozik
7 Replies

10. Shell Programming and Scripting

Grep/awk/sed help

got a file as y.txt 1 abc,def,ghj 2 defj,abc.kdm,ijk 3 lmn,cbk,mno 4 tmp,tmop,abc,pkl 5 pri,chk,cbk,lmo 6 def,cbk.pro,abc.kdm i want to search in the above file the key word like abc looking for two outcomes by passing the parameter value as abc into function and the two outocmes are... (6 Replies)
Discussion started by: silgun
6 Replies
NEWSLOG(5)							File Formats Manual							NEWSLOG(5)

NAME
newslog - description of Usenet log files DESCRIPTION
Most log files created by Usenet programs reside in the /var/log/news directory and have a ``.log'' extension. Several versions are usu- ally kept with an additional extension such as ``.1'', ``.2'', etc. -- the higher the number, the older the log. The older versions are compressed. The scanlogs script and related utilities (see newslog(8)) are responsible for rotating and compressing these files. Some log files always have data, others only have data if there is a problem, and others are only created if a particular program is used or configuration parameter is set. The innstat script (see newslog(8)) monitors the size of all log files. The following files will only accumulate data under the direction of control.ctl(5): control.log miscctl.log newgroup.log rmgroup.log unwanted.log In order to create these files, the ``message'' and ``action'' fields of control.ctl should be chosen from the following table: Message Action Meaning all log=miscctl Log all messages by default default log=miscctl Log unknown messages newgroup doit=newgroup Create group and log message newgroup log=newgroup Log message rmgroup doit=rmgroup Remove group and log message rmgroup log=rmgroup Log message ``other'' doit=miscctl log and process the message ``other'' log=miscctl Log message Here, ``other'' refers to any other control message such as: checkgroups ihave sendme sendsys senduuname version The following is a list of log files. control.log This file maintains a count of the number of newgroup and rmgroup control messages seen for each newsgroup. The count is of the number of control messages with identical arguments, regardless if they were actually processed. All control arguments, including invalid ones, are counted. This file is updated by tally.control, which is invoked by scanlogs if either the newgroup or rmgroup logs exist. This file is not rotated. errlog This file contains the standard output and standard error of any program spawned by innd(8). The most common programs are the con- trol-message handlers found in /usr/lib/news/control. This file should be empty. Scanlogs will print the entire contents of this log file if it is non-empty. expire.log By default, when news.daily is going to expire old news articles, it writes the date to this file, followed by any output from expire(8) and the ending date. All lines but the first are indented four spaces. miscctl.log When control.ctl is configured as described above, all control messages except newgroup and rmgroup are appended to this file by writelog. There will be a summary line describing the message and the action taken, followed by the article indented by four spa- ces, and a blank line. newgroup.log When control.ctl is configured as described above, all newgroup messages are appended to this file using the same format as for mis- cctl.log. news This file logs articles received by innd. Scanlogs summarizes the rejected articles reported in this file. news.crit All critical error messages issued by innd are appended to this file via syslog(3). This log file should be empty. Scanlogs will print the entire contents of this log file if it is non-empty. You should have the following line in your syslog.conf(5) file: news.crit /var/log/news/news.crit news.err All major error messages issued by innd are appended to this file via syslog. This log file should be empty. Scanlogs will print the entire contents of this log file if it is non-empty. You should have the following line in your syslog.conf file: news.err /var/log/news/news.err news.notice All standard error messages and status messages issued by innd are appended to this file via syslog. Scanlogs uses the awk(1) script innlog.awk to summarize this file. You should have the following line in your syslog.conf file: news.notice /var/log/news/news.notice nntpsend.log The nntpsend(8) programs appends all status messages to this file. rmgroup.log When control.ctl is configured as described above, all rmgroup messages are appended to this file using the same format as for misc- ctl.log. unwanted.log This log maintains a count of the number of articles that were rejected because they were posted to newsgroups that do not exist at the local site. This file is updated by tally.unwanted and maintained in reverse numeric order (the most popular rejected group first). This file is not rotated. HISTORY
Written by Landon Curt Noll <chongo@toad.com> and Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.6, dated 1996/09/10. SEE ALSO
control.ctl(5), ctlinnd(8), expire(8), innd(8), news.daily(8), nntpsend(8), newslog(8). NEWSLOG(5)
All times are GMT -4. The time now is 06:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy