Hello everyone,
For my research project I have to plot a lot of graphs. We use a software package called Generic Mapping Tools (GMT) for this, where you create csh scripts which call a number of gmt programs which plot to postscript files.
I've created a script which uses a foreach loop to plot a number of graphs (about 50 in total) which creates certain variables each time the loop runs. For each iteration, the command I want people's opinions on calculates the minimum and maximum value of a number of columns for each individual input file.
Each input file looks something like this:
Code:
Eastings: Northings: Depth: Distance Along Line: Spacing:
581294.06604 93871.6534648 -28.8670818761 0 1
581294.10565 93869.7182042 -28.9322498873 1.93566588256 1
...
581319.851135 92611.8496475 -31.3056972753 1260.06766847 1
581319.891719 92609.8667921 -31.321087542 1262.05093919 1
Part of the GMT package contains a function called minmax, which displays the minimum and maximum values of each column:
Code:
3d_dunes_001_ns.dat: N = 645 <581294/581320> <92609.9/93871.7> <-31.8896/-28.7709> <0/1262.05> <1/1>
The variable I need to create must have the minimum and maximum value for the 4th and 3rd columns of the input file, formatted as follows:
Code:
0/1262.05/-31.8896/-28.7709
What I've got (which works, but seems inelegant to me), is:
Code:
set plot_area=-R`cat 3d_dunes_001_ns.dat | minmax | tr "/" " " | tr "<" " " | tr ">" " " | awk '{printf "%1d %4d %2d %2d\n", $12,($13+50),($10-2),($11+2)}' | tr " " "/"`
where the tr's replace all the '<','>' and '/' with spaces, which are then made a fixed width in awk, and then correctly ordered (min_depth/max_depth/min_dist/max_dist) and a value of 2 added to each value, to buffer the extents of the plot.
So basically, I would like to know if there's a more elegant way of getting rid of the '<','>' and '/' without using 3 tr's?
Thanks