Tom's Guide | Tom's Hardware | Tom's Games | PC Safety Suite
![]() |
![]() |
![]() |
Comment:
Hi,
I need to search the string in a file & then print the 12th line before the line where this string occurs (so basically print 12th line previous to this line). I need to know how can i do this using awk?
if there is any other way anyone can suggest i would be glad.
Vinod
+1 | ![]() |
I've been told there's a 'unix provider' for NT. [cyjwin?] And I guess I should get it and learm something.
Is the an 'NT provider' for unix?
anyone?
=====================================
If at first you don't succeed, you're about average.M2
+1 | ![]() |
here's one way
[code]
awk 'NR==FNR{ array[++c]=$0;next }
/search_string/ {print array[FNR-12]}
' "file" "file"
[/code]
+1 | ![]() |
Hi Razor2.3
I forgot about WINE. I tried it way back when, maybe Mandrake 5x. It was shakey. Hopefully ut has improved in the interim.
=====================================
If at first you don't succeed, you're about average.M2
+1 | ![]() |
Hi,
I am pasting the contents of the file below. I will get similar occurances more than 50 times in one file. I need to search for the string "End the test" and then print 11th or 12th line before this line (the one with timestamps). Please test your code & send it to me.
Thx in advance
Timestamp: Wed Jul 18 04:04:23 PM EDT 2007Starting Traffic for 20 seconds...
Frame Size: 100
2/3 -> TX Frames: 1132112
2/3 -> RX Frames: 1132112
2/3 -> RX Min Latency: 314.02 usec
2/3 -> RX Max Latency: 44480.08 usec
2/3 -> RX AVG Latency: 6103.62 usec
2/3 -> 2/3 Loss: 0
2/3 -> 2/3 Loss Ratio %: 0.000000000End the test, we are at max rate: 5.133056640625
Frame Sizes (bytes): 100
Rate (%): 5.13
Avg Latency (usec): 6103.62
Min Latency (usec): 314.02
Max Latency (usec): 44480.08
Vinod
![]() |
Comparison of strings in ...
|
Batch file to find drive ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.