-240.451527 -240.5213996
-240.451527 -240.5213996
-240.4273718 -240.4956636
-240.4515273 -240.5214005
!...two empty lines should be here...
!...because of no numbers following "1D1.log" "1D2.log" in the input file, we should use two empty lines instead of them.
-319.0829339 -319.177099
Not really. some did, but some logs have nothing follow it. Is this question clear? I just want to put the two numbers which behind the log in the same row.
---------- Post updated at 07:48 PM ---------- Previous update was at 07:42 PM ----------
Excellent script! It works well. But could you please help me to improve a little bit? If there are no numbers following the *log, we should put an empty line in the output. See the modified questing. Thank you very much! ....zhen
Perfect! It works. But I was so confused with this powerful script.
How did you put these empty lines?
Could you explain me something about this script.
I really want to learn something from here.
Thank you very much!
Very strange thing took place! see the following lines
I thought they are exactly the same code. But the outputs are totally different. The first line gave the correct output but the second line didn't.
Why? It's so strange that I cannot understand.
Output with the code of the first line
I took the lazy option of modifying the original script
/.log/ && P { print "" } # if the last line had ".log" in it (P > 0) print a blank line
/.log/ { P=1 } # indicate we have a line with ".log" in it, the above line will evaluate to true if the next line has a ".log" in it
/^HF/ { printf $2 " "; getline; print $2; P=0 }
If a line starts with HF get the next line and print both together, reset P to say this line doesn't have ".log" in it. The HF= part is removed by using = as the field separator (-F=)
Or something like that!
I wouldn't really describe it as powerful.
---------- Post updated at 02:28 PM ---------- Previous update was at 01:47 PM ----------
They're not the same. The second one has a lowercase p in the /^HF/ action. Variable names are case-sensitive in UNIX (almost universally so).
I should have used a less ambiguous variable name than P (which does look like p)!
(instead of editing your previous posts, it helps if you reply to the thread. that way I can see your updates more easily - I'm notified that way)