Who can help me?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Who can help me?
# 1  
Old 02-11-2015
Who can help me?

Hi guys i m just starting with unix but actually i need to parse this log ...
Statistic log.

Code:
2015-02-10 10:00:03,474|INFO |EMT-(00) |> [9] KPI # trasm:1266245958 retrasm:439137 dropped:36504
2015-02-10 10:00:03,520|INFO |EMT-(04) |> [9] KPI # trasm:1339998535 retrasm:86120 dropped:47549
2015-02-10 10:00:03,541|INFO |EMT-(02) |> [9] KPI # trasm:1362335738 retrasm:84469 dropped:48248
2015-02-10 10:00:03,543|INFO |EMT-(01) |> [9] KPI # trasm:1362335738 retrasm:84469 dropped:4824
2015-02-10 10:00:03,544|INFO |EMT-(03) |> [9] KPI # trasm:1362335738 retrasm:84469 dropped:4824

I did it using AWK and sed (-e) but someone of my team want his by a script...
the result has to be this

Code:
2015-02-10 10:00 Newname1 trasm:1339998535 retrasm:86120 dropped:47549

and so on...with Newname2....3...4 ...for the EMT.

Last edited by Don Cragun; 02-11-2015 at 05:21 AM.. Reason: Add CODE tags.
# 2  
Old 02-11-2015
From the data you have shown, I have no idea what you are trying to do.

And, please use CODE tags when showing sample input, output, and code segments.

What operating system and shell are you using?

Is the idea that you take the second record from each set of input records with the same hour and minute, throw away the other records for that hour and minute, and replace everything from the 3rd colon through the 1st octothorp on the line you keep with Newnamen with increasing values of n for each hour and minute in your log?
# 3  
Old 02-11-2015
So why doesn't "someone of your team" do the script?

---------- Post updated at 10:44 ---------- Previous update was at 10:42 ----------

Anyhow, try sth. like
Code:
while read DAY TIME A B C D E TRASM RETR DR; do echo $DAY ${TIME%:*} "NEWNAME$((++CNT))" $TRASM $RETR $DR; done < file3
2015-02-10 10:00 NEWNAME1 trasm:1266245958 retrasm:439137 dropped:36504
2015-02-10 10:00 NEWNAME2 trasm:1339998535 retrasm:86120 dropped:47549
2015-02-10 10:00 NEWNAME3 trasm:1362335738 retrasm:84469 dropped:48248
2015-02-10 10:00 NEWNAME4 trasm:1362335738 retrasm:84469 dropped:4824
2015-02-10 10:00 NEWNAME5 trasm:1362335738 retrasm:84469 dropped:4824

in bash (or other recent shell).
# 4  
Old 02-11-2015
Hi, I m sorry i didn't read the form rules and actually i still don't know a lot of things about unix. What i've to do is to format this logs to load it in a DB. The result has to be with timestamp to the minutes (so as it is from the log,just i m not interested in milliseconds) . After that I need to change the name EMTxx in other names, i 've 5 EMT from 0 to 4 and i want just change it to make it clear what the emitter is for that line! Thank you so much ...and forgive my english, i know is not the best one!

---------- Post updated at 11:20 AM ---------- Previous update was at 10:50 AM ----------

Thanks RUDIC it works,i think it has been really easy for you, i want learn...so i ve' to study. Just a little things the new name has not to increase but just change the emt01 with newname01 and so on til the number 05. I'll try to change the code you posted. Hope to do it in the right way
# 5  
Old 02-11-2015
Compare what you did to e.g.
Code:
while read DAY TIME A B C D E TRASM RETR DR; do echo $DAY ${TIME%:*} NEWNAME${A//[^0-9]} $TRASM $RETR $DR; done < file3
2015-02-10 10:00 NEWNAME00 trasm:1266245958 retrasm:439137 dropped:36504
2015-02-10 10:00 NEWNAME04 trasm:1339998535 retrasm:86120 dropped:47549
2015-02-10 10:00 NEWNAME02 trasm:1362335738 retrasm:84469 dropped:48248
2015-02-10 10:00 NEWNAME01 trasm:1362335738 retrasm:84469 dropped:4824
2015-02-10 10:00 NEWNAME03 trasm:1362335738 retrasm:84469 dropped:4824

You see that the more time you invest into the specification of a task the less it takes to implement it.
# 6  
Old 02-11-2015
I did it...thank you so much. You are right " more time you invest into the specification of a task the less it takes to implement it."
# 7  
Old 02-11-2015
If you put a thread title like "Who can help me?" then nobody will help you because nobody has a clue what your question is about!!!! The thread title should give the whole community some clue as to what you want help with.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question