Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 02-14-2015, 12:00 PM   #1
LQ Newbie
Registered: Sep 2008
Location: TX
Posts: 3

Rep: Reputation: Disabled
Log parsing

Hi, I'm trying to use awk to parse multiple strings from a fw log file

I need awk to parse for the following structure: 3 IPs in an OR sequence AND string1 AND string2 (IP or IP or IP) && string1 && string2

I'm unable to craft a command that looks for IP 1, 2, or 3 and string 1 or string 2. Below is some of the syntax structure I've tried so far but to no avail. I believe the OR statement is incorrect as the AND arguments appear to be working

cat file |awk /IP/ || /IP/ || /IP/ && /string1/ && /string2/

Last edited by Buhlz_I; 02-14-2015 at 12:02 PM.
Old 02-14-2015, 12:26 PM   #2
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
in your post you have parentheses but in the actual command there are none. Since && has higher precedence than ||, it actually translates to

cat file |awk /IP/ || /IP/ || (/IP/ && /string1/ && /string2/)
also, you don't need the cat command, awk will accept an input file as an argument.


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
Log parsing but issue with log rotation Rohant Linux - Server 1 05-30-2013 09:09 PM
Need help with parsing log file sysmicuser Linux - Newbie 5 03-10-2012 05:50 PM
Parsing a log file jpostma Linux - Newbie 5 12-05-2008 03:58 PM
Help Parsing Log files blacky777 Linux - Security 6 04-21-2004 01:06 PM
parsing log files jstu Linux - General 4 06-10-2003 07:26 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:53 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