AnotherAlan
Technical User
Hi,
I have a sample file produced from a sql statement that I would like to format into something excel readable. The data is produced for each hour so the full file will contain 36 rows minimum;
Sample data;
GTS 56
FID 78
WCK 92
GTS 50
FID 70
WCK 136
..
..
..
GTS 45
e.tc.
What I would like is this;
GTS 56 50 .. .. 45
FID 78 70 .. .. 32
WCK 92 136 .. .. 78
I'm struggling with it though; what i've come up with so far is this;
grep GTS output.log1 | awk 'NR==1 {printf "%s ", $1} {printf "%s ", $2} END {printf "\n"}'
but this is not elegant and would involve multiple greps and a little further processing to get the format correct.
I've tried using awk pattern matching but it gave some spurious result;
awk '/GTS/ {printf "%s ", $1} {printf "%s ", $2} END {printf "\n"}' output.log1
GTS 56 78 92 GTS 50 70 136
Any suggestions on how I could go about improving this?
All help appreciated.
Thanks
Alan
I have a sample file produced from a sql statement that I would like to format into something excel readable. The data is produced for each hour so the full file will contain 36 rows minimum;
Sample data;
GTS 56
FID 78
WCK 92
GTS 50
FID 70
WCK 136
..
..
..
GTS 45
e.tc.
What I would like is this;
GTS 56 50 .. .. 45
FID 78 70 .. .. 32
WCK 92 136 .. .. 78
I'm struggling with it though; what i've come up with so far is this;
grep GTS output.log1 | awk 'NR==1 {printf "%s ", $1} {printf "%s ", $2} END {printf "\n"}'
but this is not elegant and would involve multiple greps and a little further processing to get the format correct.
I've tried using awk pattern matching but it gave some spurious result;
awk '/GTS/ {printf "%s ", $1} {printf "%s ", $2} END {printf "\n"}' output.log1
GTS 56 78 92 GTS 50 70 136
Any suggestions on how I could go about improving this?
All help appreciated.
Thanks
Alan