我有一个巨大的文本文件,如下所示:
36,53,90478,0.58699759849,0.33616,4.83449759849,0.0695335954050315,3
36,53,90478,0.58699759849,0.33616,4.83449759849,0.0695335954050315,8
36,53,90478,0.58699759849,0.33616,4.83449759849,0.0695335954050315,14
36,53,15596,0.58454577855,0.26119,2.24878677855,0.116147072052964,12
所需的输出是这样的:
36,53,90478,0.58699759849,0.33616,4.83449759849,0.0695335954050315,MI-03
36,53,90478,0.58699759849,0.33616,4.83449759849,0.0695335954050315,MI-08
36,53,90478,0.58699759849,0.33616,4.83449759849,0.0695335954050315,MI-14
36,53,15596,0.58454577855,0.26119,2.24878677855,0.116147072052964,MI-12
我曾在这里和其他社区尝试过其他相关职位,但无法完全得到我想要的东西。
更新
这是交叉询问(我想要Unix / perl答案和批处理/ powershell解决方案。),它有有趣的答案。
"1 2 3 4" | awk '{$2=$2;print $0}'
给出:(1 2 3 4
字段之间仅剩1个空格(或OFS))。ex2)echo "1,,,2,3,,,,4" | awk -F',' '{$2=$2;print $0}'
给出:(1 2 3 4
逗号变为空格)。可能还有其他副作用。如果辅助字段具有有害的副作用,请测试并采取另一种方法(例如,复制变量$ 0上的gsub)。