我有一个1.5GB的数据格式,几乎按照我想要的方式格式化,但我需要将BSSID转换为更多的MAC地址可读格式。
我的输入数据如下所示:
id,data_source,bssid,lat,lon,range,updated,created
1155506572,-1,0037B78D708D,45.77844080,4.80769845,140.00,1469833291,1469833291
1155506595,-1,F4CAE5E78AD4,45.78175649,4.81046725,140.00,1469833291,1469833291
1155506641,-1,18622CACD9BC,45.76656373,4.81941711,140.00,1469833291,1469833291
1155506661,-1,4883C72CC295,45.78551839,4.81023433,140.00,1469833291,1469833291
1155506677,-1,000B3BD19CAF,45.77941868,4.80828591,140.00,1469833291,1469833291
1155506696,-1,0007CB08471D,45.76691825,4.82602490,140.00,1469833291,1469833291
但我需要它看起来像这样:
id,data_source,bssid,lat,lon,range,updated,created
1155506572,-1,00:37:B7:8D:70:8D,45.77844080,4.80769845,140.00,1469833291,1469833291
1155506595,-1,F4:CA:E5:E7:8A:D4,45.78175649,4.81046725,140.00,1469833291,1469833291
1155506641,-1,18:62:2C:AC:D9:BC,45.76656373,4.81941711,140.00,1469833291,1469833291
1155506661,-1,48:83:C7:2C:C2:95,45.78551839,4.81023433,140.00,1469833291,1469833291
1155506677,-1,00:0B:3B:D1:9C:AF,45.77941868,4.80828591,140.00,1469833291,1469833291
1155506696,-1,00:07:CB:08:47:1D,45.76691825,4.82602490,140.00,1469833291,1469833291
答案 0 :(得分:0)
OR
awk -F, -v OFS=, 'NR>1{$3=substr($3,1,2) ":" substr($3,3,2) ":" substr($3,5,2) ":" substr($3,7,2) ":" substr($3,9,2) ":" substr($3,11,2)}1' file
id,data_source,bssid,lat,lon,range,updated,created
1155506572,-1,00:37:B7:8D:70:8D,45.77844080,4.80769845,140.00,1469833291,1469833291
1155506595,-1,F4:CA:E5:E7:8A:D4,45.78175649,4.81046725,140.00,1469833291,1469833291
1155506641,-1,18:62:2C:AC:D9:BC,45.76656373,4.81941711,140.00,1469833291,1469833291
1155506661,-1,48:83:C7:2C:C2:95,45.78551839,4.81023433,140.00,1469833291,1469833291
1155506677,-1,00:0B:3B:D1:9C:AF,45.77941868,4.80828591,140.00,1469833291,1469833291
1155506696,-1,00:07:CB:08:47:1D,45.76691825,4.82602490,140.00,1469833291,1469833291
IHTH
答案 1 :(得分:0)
$ awk 'BEGIN{FS=OFS=","} NR>1{gsub(/../,"&:",$3); sub(/:$/,"",$3)} 1' file
id,data_source,bssid,lat,lon,range,updated,created
1155506572,-1,00:37:B7:8D:70:8D,45.77844080,4.80769845,140.00,1469833291,1469833291
1155506595,-1,F4:CA:E5:E7:8A:D4,45.78175649,4.81046725,140.00,1469833291,1469833291
1155506641,-1,18:62:2C:AC:D9:BC,45.76656373,4.81941711,140.00,1469833291,1469833291
1155506661,-1,48:83:C7:2C:C2:95,45.78551839,4.81023433,140.00,1469833291,1469833291
1155506677,-1,00:0B:3B:D1:9C:AF,45.77941868,4.80828591,140.00,1469833291,1469833291
1155506696,-1,00:07:CB:08:47:1D,45.76691825,4.82602490,140.00,1469833291,1469833291