Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process files for excel use 1

Status
Not open for further replies.

jdespres

MIS
Aug 4, 1999
230
US
I have been collecting data all weekend on the hour...

Each file has the following format:

Sat Jul 29 12:00:00 EDT 2006
server1 numerical_data1
server2 numerical_data2
server3 numerical_data3
server4 numerical_data4
server5 numerical_data5
server6 numerical_data6
server7 numerical_data7
server8 numerical_data8

Sat Jul 29 13:00:00 EDT 2006
server1 numerical_data1
server2 numerical_data2
server3 numerical_data3
server4 numerical_data4
server5 numerical_data5
server6 numerical_data6
server7 numerical_data7
server8 numerical_data8

I would like to collect all data into one file ready for import into excel:

Jul 29 12:00:00 Jul 29 13:00:00 Jul 29 14:00:00
server1 numerical_data1 numerical_data1 numerical_data1 ..
server2 numerical_data2 numerical_data2 numerical_data2 ..
server3 numerical_data3 numerical_data3 numerical_data3 ..
server4 numerical_data4 numerical_data4 numerical_data4 ..
server5 numerical_data5 numerical_data5 numerical_data5 ..
server6 numerical_data6 numerical_data6 numerical_data6 ..
server7 numerical_data7 numerical_data7 numerical_data7 ..
server8 numerical_data8 numerical_data8 numerical_data8 ..

There's atleast 48 files.......

I was going to just manually cut and paste....

But I'm hoping there's a better way....

Thanks.......

Joe Despres
 
Hi

There is an adequate tool, someone will tell you which. Until then, an [tt]awk[/tt] :
Code:
awk 'NR==FNR{s[FNR]=(FNR==1?FS:"")$0;next}{$1=FS (FNR==1?$1:"");s[FNR]=s[FNR]$0}END{for(i=1;i in s;i++)print i,s[i]}' /input/f*
Tested with [tt]gawk[/tt] and [tt]mawk[/tt].

Feherke.
 
$ awk 'NR==FNR{s[FNR]=(FNR==1?FS:"")$0;next}{$1=FS (FNR==1?$1:"");s[FNR]=s[FNR]$0}END{for(i=1;i in s;i++)print i,s}' VolumeAmount.rpt*
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
awk: illegal statement near line 1
 
hhhhhmmmmm....
.
Using awk on a Solaris 9.....
.
I do have access to nawk....
.
It seems to work....
.
The output doesn't seem to be ok....
 
Hi

jdespres said:
The output doesn't seem to be ok...
If you tell us why doesn't seem to be ok, we could help more efficiently...

Maybe you want a proper separator instead of [tt]FS[/tt] ?
Code:
awk 'NR==FNR{s[FNR]=(FNR==1?[red]"\t"[/red]:"")$0;next}{$1=[red]"\t"[/red] (FNR==1?$1:"");s[FNR]=s[FNR]$0}END{for(i=1;i in s;i++)print i,s[i]}' /input/f*

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top