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. |
Quote:
|
Quote:
|
All times are GMT -5. The time now is 06:07 AM. |