LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-14-2015, 12:00 PM   #1
Buhlz_I
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
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

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

Code:
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.
 
  


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
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

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

All times are GMT -5. The time now is 10:57 PM.

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