LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-19-2004, 11:36 AM   #1
jonsag
LQ Newbie
 
Registered: Dec 2004
Posts: 4

Rep: Reputation: 0
select certain subjects in syslog


if i do

cat /var/log/syslog | grep antip2p

i get a number of lines looking like this:
Dec 19 17:44:59 p2-266 kernel: antip2p IN=eth0 OUT= MAC=**:**:**:**:**:**:**:**:**:**:**:**:** SRC=222.88.173.5 DST=***.***.***.*** LEN=668 TOS=0x00 PREC=0x00 TTL=102 ID=30078 PROTO=UDP SPT=2244 DPT=1026 LEN=648

(the *:s is ofcourse not there originally)

if i would like it to look something like this:
Dec 19 17:44:59 SRC=222.88.173.5
what do I do?

is this possible to do in bash?
 
Old 12-19-2004, 12:01 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
awk is the tool to use. you can select search terms, and format the output. example: the log file is x number of columns wide. you select which columns to print by specifying $1, $2, $3, etc, to indicate which columns to show.

feed the output of cat /var/log/syslog to awk via pipe.
cat /var/log/syslog | awk ' {antip2p print $3, $2, $4, $1, $5, $9, $7, $8, $6}' , or something along those lines. As you can see, the order of the columns to print can be specified to your liking.

PS: I probably have a syntax error in the awk statement, but can't see it right off hand.

Last edited by bigrigdriver; 12-19-2004 at 12:03 PM.
 
Old 12-19-2004, 12:05 PM   #3
jonsag
LQ Newbie
 
Registered: Dec 2004
Posts: 4

Original Poster
Rep: Reputation: 0
excellent

many thanks

will have to learn more about awk
can perhaps solve some more problems of mine
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
select jhon Programming 5 11-01-2005 09:46 PM
Select() did not select my socket thvo Programming 1 05-08-2005 12:20 AM
need books on some math related subjects weepenguin Linux - General 1 04-05-2005 07:06 PM
need books on some math related subjects weepenguin General 0 04-05-2005 03:21 PM
Spamassassin: Add _SCORE_ to start of ham subjects with procmail birdseye Linux - Software 0 03-24-2005 10:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration