Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-19-2004, 12:36 PM   #1
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= 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=
what do I do?

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

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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 01:03 PM.
Old 12-19-2004, 01:05 PM   #3
LQ Newbie
Registered: Dec 2004
Posts: 4

Original Poster
Rep: Reputation: 0

many thanks

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:46 PM
Select() did not select my socket thvo Programming 1 05-08-2005 01:20 AM
need books on some math related subjects weepenguin Linux - General 1 04-05-2005 08:06 PM
need books on some math related subjects weepenguin General 0 04-05-2005 04:21 PM
Spamassassin: Add _SCORE_ to start of ham subjects with procmail birdseye Linux - Software 0 03-24-2005 11:57 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:18 PM.

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