Friday 27 June 2008

Munge columnar into one datafile (for processing in a spreadsheet, gnuplot or whatever)

Often we'll use awk or cut to spit out a single column of data from a bunch of different files, or maybe from the same file... anyhow once we have these files with one column of data, sometimes we'll want to splice those files together so we can look at each line (typically a stat of some sort) next to each other. Also it's very convenient if we want to import the data into a spreadsheet.

Anyhow, let's say I have three files iscsi_080626.txt greads.out.txt idle.out.txt. I can put them together into one file using the 'pr' command like so.

iscsi file
bash-3.00$ head iscsi_080626.txt 
32782319.86
32793022.93
32734064.23
32719233.74
32652552.75
32815570.70


gread file
bash-3.00$ head greads.out.txt

0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00


idle file
bash-3.00$ head idle.out.txt 
248.722142
17.662915
17.195024
16.208969
15.856432
17.064519
16.874948
17.122956
17.191305
16.920703





bash-3.00$ pr -m -t iscsi_080626.txt greads.out.txt idle.out.txt > iscsi_greads_idle.txt


And the output file looke like this
bash-3.00$ head iscsi_greads_idle.txt 
32782319.86 0.00 248.722142
32793022.93 0.00 17.662915
32734064.23 0.00 17.195024
32719233.74 0.00 16.208969
32652552.75 0.00 15.856432
32815570.70 0.00 17.064519
32801494.63 0.00 16.874948
32696942.10 0.00 17.122956
32715608.64 0.00 17.191305
32835538.38 0.00 16.920703

No comments: