Thanks for your reply.... this is working for the data I gave... but in actual file i also have strings with spaces and it could have : / as well.... but file is comma separated.
eg:
Input file:
number, number, date time, number, string, string
123456789,98765432,9/8/2012 3:00,1, ABC ABC, NEW STRING (12/3)
Need output:
date , time , number , number, number, string, string
20130809,030000,123456789,98765432,1, ABC ABC, NEW STRING (1:23)
Please advise. Sorry for not giving complete data before!
So is the transformation of xy/z to x:yz supposed to occur in both string fields or only in the last field? Will that transformation always be for 2 digits followed by a slash followed by a single digit, or is there some more general pattern?
PLEASE use code tags as demanded!
I expect your specification to change again, for the 4th time, e.g. to accomodate for fields in double quotes as normally used in .csv files. And, how and why did field 6 change from ...12/3 to 1:23?
Why don't you give it a try yourself, having seen so many examples in the replies to your posts? Anyhow, use this as a starting point:
awk -F , '{
split($3,a," ")
var1=a[1]
var2=a[2]
split(var1,a,"/")s ### Separate date
printf("%02s%02s%02s,",a[3],a[2],a[1])
split(var2,b,":") ### Separate time
printf("%02s%02s00, ,",b[1],b[2])
### End of date and time
printf("%s,%s,%s, , ,0,%s, , , ,I, , , ,\n",$1,$2,$4,$7)
}' a.csv