Wednesday, 18 September 2013

awk or sed , whichever is more apt

awk or sed , whichever is more apt

reading a csv file in unix and, doing some substitution on some of the
columns. like 2nd column(string type) should be replaced by value of (2nd
column itself + value of the 1st column(integer)), then 5th column by
$5+$4 and so on. Below is the sample I/O. and the first line which is
Description must be left as is .
sample Input
EmpID|Empname|Empadd|roleId|roleDesc|Dept
100|mst|Del|20|SD|DA
101|ms|Del|21|XS|DA
Sample output
EmpID|Empname|Empadd|roleId|roleDesc|Dept
100|mst100|Del|20|SD20|DA
101|ms101|Del|21|XS21|DA
empname has been concatenated with empid & the role desc with roleID.Hope
that's helpful :)

No comments:

Post a Comment