linux - How to append new column using output from print command in awk? -


i'm trying add result of print statement new column in file t1.dat:

awk '/time in seconds/ {print $5}' bt.b.1.log > t1.dat awk '/total processes/ {print $4; exit}' bt.b.1.log >> t1.dat 

contents of bt.b.1.log:

time in seconds = 260.37
total processes = 1

output: (t1.dat)

260.37 1 

desired output:

260.37 1 

but, now, awk appending new line in t1.dat. how append new column in existing file (in case, t1.dat), without using intermediate files?

awk 'begin{ors=" "} {if(nr==1) {print $5} else {print $4}}' bt.b.1.log 

ors abbreviation output records separator. perhaps ed morton has easier way of doing it.

alternatively:

awk '{if(nr==1) {printf $5} else {printf " "$4"\n"}}' bt.b.1.log 

do want line break @ end or not?


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -