LQ Newbie
Registered: Nov 2006
Posts: 8
Rep:
|
Linux scripting for text editing... help needed
I have several hundred map calibration files - that for historical reasons contain a systematic error. The algorithm for fixing them is very simple - but it is very tedious to do it manually. I think awk and/or sed can probably help...
I need to take the two numbers in the 3rd and 4th columns of line 11 of each file - and copy it to columns 3 and 4 of line 56 - replacing the numbers currently in that position.
The files are comma delimited text files - and the relevant lines have unique text in them if that is helpful for searching. Here is an example of a file containing the error.
----------------
OziExplorer Map Data File Version 2.2
SE5308 Calvert Hills
\\C5\Backups\PDA Storage card\Maps\Natmap 2003 CD1\osf\se5308.ozf2
1 ,Map Code,
Australian Geocentric 1994 (GDA94),, 0.0000, 0.0000,WGS 84
Reserved 1
Reserved 2
Magnetic Variation,,,E
Map Projection,(UTM) Universal Transverse Mercator,PolyCal,No,AutoCalOnly,No,BSBUseWPX,No
Point01,xy, 0, 0,in, deg, , ,, , ,, grid, 53, 601927.125, 8126091.88,S
Point02,xy, 7134, 4022,in, deg, , ,, , ,, grid, 53, 828431.625, 7998393.38,S
Point03,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point04,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point05,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point06,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point07,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point08,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point09,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point10,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point11,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point12,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point13,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point14,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point15,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point16,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point17,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point18,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point19,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point20,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point21,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point22,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point23,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point24,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point25,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point26,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point27,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point28,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point29,xy, , ,in, deg, , ,, , ,, grid, , , ,
Point30,xy, , ,in, deg, , ,, , ,, grid, , , ,
Projection Setup,,,,,,,,,,
Map Feature = MF ; Map Comment = MC These follow if they exist
Track File = TF These follow if they exist
Moving Map Parameters = MM? These follow if they exist
MM0,Yes
MMPNUM,4
MMPXY,1,1819,199
MMPXY,2,6851,253
MMPXY,3,6796,3745
MMPXY,4,1792,3681
MMPLL,1, 136.500010, -17.000543
MMPLL,2, 137.999941, -16.999450
MMPLL,3, 137.999951, -18.000490
MMPLL,4, 136.500136, -17.999562
MM1B,31.749907
MOP,Map Open Position,0,0
IWH,Map Image Width/Height,2500,1395
-------------------
In this case the last line should be corrected to read:
IWH,Map Image Width/Height,7134, 4022
Is anyone able to get me started with some awk or sed commands?
Thanks
Richard.
|