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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifiying a Column/Record while keeping format 1

Status
Not open for further replies.

RulMorf

Technical User
Jul 19, 2013
14
0
0
MX
Hi Guys, I have a problem which I know I can Fix with awk, sed or PERL, but I'm just a beginner using those tools.

Here is it.

I have a large file like this:
__576429.250_2161394.750____2708.832_24_1_1DepthTDQ2012MIOZaap24iLimSSEIMP____________LGC
__577503.500_2162441.750____3952.155_24_1_2DepthTDQ2012MIOZaap24iLimSSEIMP____________LGC
__577722.812_2162655.500____4346.954_24_1_2DepthTDQ2012MIOZaap24iLimSSEIMP____________LGC
__577973.500_2162899.750____4801.474_24_1_2DepthTDQ2012MIOZaap24iLimSSEIMP____________LGC
__578092.062_2163015.250____5021.743_24_1_3DepthTDQ2012MIOZaap24iLimSSEIMP____________LGC
__575034.125_2165620.500____2556.695_24_1_1DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574559.688_2165158.250____3204.005_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574241.875_2164848.500____3787.890_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574183.625_2164791.750____3882.056_24_1_3DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__575112.375_2165522.250____2550.740_24_1_1DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574624.438_2165046.750____3295.139_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574472.312_2164898.500____3587.907_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574293.250_2164724.000____3907.159_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574132.125_2164567.000____4077.007_24_1_3DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__575266.750_2165498.250____2548.748_24_1_1DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__575119.062_2165354.250____2753.772_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574501.375_2164752.250____3764.174_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574286.562_2164543.000____4044.122_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574111.938_2164372.750____4287.866_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC
__574013.438_2164276.750____4416.478_24_1_3DepthTDQ2012MIOZaap23iLimNSWIMP___________LGC

NOTE: Underscores ( _ ) are actually blanks (whithespaces).

I need to append a _v1 to the fifth column while preserving the number at the beginning of the record and, (very important) maintaining the format/spaces between records/columns.

Desired Output:

__576429.250_2161394.750____2708.832_24_1_1DepthTDQ2012MIOZaap24iLimSSEIMP.v1_________LGC
__577503.500_2162441.750____3952.155_24_1_2DepthTDQ2012MIOZaap24iLimSSEIMP.v1_________LGC
__577722.812_2162655.500____4346.954_24_1_2DepthTDQ2012MIOZaap24iLimSSEIMP.v1_________LGC
__577973.500_2162899.750____4801.474_24_1_2DepthTDQ2012MIOZaap24iLimSSEIMP.v1_________LGC
__578092.062_2163015.250____5021.743_24_1_3DepthTDQ2012MIOZaap24iLimSSEIMP.v1_________LGC
__575034.125_2165620.500____2556.695_24_1_1DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574559.688_2165158.250____3204.005_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574241.875_2164848.500____3787.890_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574183.625_2164791.750____3882.056_24_1_3DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__575112.375_2165522.250____2550.740_24_1_1DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574624.438_2165046.750____3295.139_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574472.312_2164898.500____3587.907_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574293.250_2164724.000____3907.159_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574132.125_2164567.000____4077.007_24_1_3DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__575266.750_2165498.250____2548.748_24_1_1DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__575119.062_2165354.250____2753.772_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574501.375_2164752.250____3764.174_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574286.562_2164543.000____4044.122_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574111.938_2164372.750____4287.866_24_1_2DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC
__574013.438_2164276.750____4416.478_24_1_3DepthTDQ2012MIOZaap23iLimNSWIMP.v1________LGC


NOTE: Underscores ( _ ) are actually blanks (whithespaces).

I know I can do it with awk using sub and split but I'm suffering here.

Thanks in advance
 
Sorry guys, actually it is the Sixth column.

 
A starting point:
Code:
awk '{x=$0;sub($6"   ",$6".v1",x);print x}' /path/to/input >output

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks a lot PHV. Gonna work on that
 
It works.

Great!!!.


AWK is powerful and useful ( once you get to know how it works ).


Thanks againg PHV.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top