LinuxQuestions.org
Help answer threads with 0 replies.
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 07-14-2015, 12:31 AM   #1
ablopera
LQ Newbie
 
Registered: Jul 2015
Distribution: Centos 6.2
Posts: 14

Rep: Reputation: Disabled
How to manipulate values in a log file


Hi Guys, need some assistance on the log file being created by my script. Please see below details:

[/code]
Script:

#!/bin/bash

# Get the first value, which we will compare to the other
# values further down in the file.
STATIC=$(sed -n 4p POSData.log)

# Loop through the file to see if the STATIC value
# matches the other values VALUE
for i in $(seq -w 01 63); do
if grep -q "TID $i" POSData.log; then
VALUE=$(grep -A 3 "TID $i" POSData.log | tail -1)
if [ $STATIC == $VALUE ]; then
echo "Match."
else
echo "TID $i PLU Count ($VALUE ) is not matched with the Server Count ($STATIC )" >> PLUComp.log

fi
fi

done

============================

[/output]
Source Log

LINUX SERVER
count
--------
331435
(1 row)

=======================

TID 01
count
--------
331435
(1 row)

=======================

TID 02
count
--------
331435
(1 row)

=======================

TID 03
count
--------
331439
(1 row)

=======================

TID 04
count
--------
331435
(1 row)

=======================

TID 05
count
--------
No Route To Host
(1 row)

=======================

TID 06
count
--------
331438
(1 row)

=======================

TID 07
count
--------
No Route To Host
(1 row)

=======================

TID 08
count
--------
No Route To Host
(1 row)

=======================

TID 09
count
--------
No Route To Host
(1 row)

=======================

[/output]
Output Log

TID 03 PLU Count ( 331439 ) is not matched with the Server Count ( 331435 )
TID 05 PLU Count (No Route To Host ) is not matched with the Server Count ( 331435 )
TID 06 PLU Count ( 331438 ) is not matched with the Server Count ( 331435 )
TID 07 PLU Count (No Route To Host ) is not matched with the Server Count ( 331435 )
TID 08 PLU Count (No Route To Host ) is not matched with the Server Count ( 331435 )
TID 09 PLU Count (No Route To Host ) is not matched with the Server Count ( 331435 )

What I want to do is to reflect the following below in the logfile.

If client PC is online reflect this:
TID 03 PLU Count ( 331439 ) is not matched with the Server Count ( 331435 )

If the client PC is offline/cannot be reached, reflect this:
No Route To Host

I added additional condition in the script, but to no avail.

Last edited by ablopera; 07-14-2015 at 01:41 AM.
 
Old 07-14-2015, 01:07 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,049

Rep: Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915
Quote:
Originally Posted by ablopera View Post
I added additional condition in the script, but to no avail.
Show us - and use [code] ... [/code] tags when posting code (or output).
 
1 members found this post helpful.
Old 07-14-2015, 01:39 AM   #3
ablopera
LQ Newbie
 
Registered: Jul 2015
Distribution: Centos 6.2
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Show us - and use [code] ... [/code] tags when posting code (or output).
Hi syg00, got it. My apologies, Im only new here and still learning. Will do it on my succeding post. Thanks.
 
  


Reply


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
How to manipulate a range of columns in a file using awk ksvinaykumar Linux - Newbie 8 04-10-2012 10:11 AM
grep multiple values in single pass through log file. 1ankit1 Programming 2 11-13-2010 05:45 PM
[SOLVED] Manipulate text file to allow import to excel dimothy Linux - Software 3 06-14-2010 08:50 AM
Replace values in log file laki47 Linux - Newbie 5 05-14-2010 10:41 AM
Best Way to manipulate a text file.. php ? 8rucech85 Programming 2 01-30-2008 05:35 AM


All times are GMT -5. The time now is 12:25 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration