![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 03:31 PM |
| Shell Script: want to insert values in database when update script runs | ring | Shell Programming and Scripting | 1 | 10-25-2007 03:06 AM |
| here document to automate perl script that call script | hogger84 | Shell Programming and Scripting | 3 | 10-22-2007 10:15 AM |
| returning to the parent shell after invoking a script within a script | gurukottur | Shell Programming and Scripting | 5 | 09-26-2006 07:05 AM |
| return valuse from child script to parent script | borncrazy | Shell Programming and Scripting | 1 | 08-20-2004 03:39 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
AWK/SED script help
Hi, was hoping someone may be able to help me with a script solution to move one line to another line from my log file:
My log file currently looks like this: 01:21:12:383 Request 01:21:12:639 Response 01:21:12:386 Request 01:21:12:639 Response 01:21:12:389 Request 01:21:12:640 Response 01:21:12:610 Request 01:21:12:646 Response 01:21:12:645 Request 01:21:12:673 Response I want it to look like this: 01:21:12:383 Request 01:21:12:639 Response 01:21:12:386 Request 01:21:12:639 Response 01:21:12:389 Request 01:21:12:640 Response 01:21:12:610 Request 01:21:12:646 Response 01:21:12:645 Request 01:21:12:673 Response I'm thinking sed would probably be best for this but so far I cannot seem to get it to work ![]() Any advice would be most welcome.. Cheers, Jim |
|
||||
|
more help required please...
i'm still a bit of a novice here and assumed I would be able to figure this out for myself but could do with some more advice please...
now I have my log file in this format: 01:11:15:423 Request 01:11:15:541 Response 01:11:15:424 Request 01:11:15:514 Response 01:11:15:436 Request 01:11:15:678 Response 01:11:15:516 Request 01:11:15:675 Response I would like to calculate the total response time in ms by subtracting $1 from $3 and print the result in a new field at the end of each row: 01:11:15:423 Request 01:11:15:541 Response 118 I thought I might be able accomplish this with some sort of awk script but things seem to get complicated (for me) when dealing with the time stamp. If anyone could advise the best way forward for this I'd really appreciate it. Jim |
|
||||
|
just one of the many ways, you can do hard maths...:
Code:
awk '
{
n=split($1,one,":")
hh=one[1]
mm=one[2]
ss=one[3]
ms=one[4] #i assume its milleseconds?
m=split($3,three,":")
....
...
#do time maths..convert everything to seconds,
result = result_of_three(secs) - result_of_one(secs)
}
{ print $0 " " result }
' "file"
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|