需要您的专家建议
输入:
2020-01-1713:57:5888823,aJ,MO,ZXC,adf
2020-01-1713:58:3878823,sJ,MO,AXC,Ldf
2020-01-1713:59:1898823,DJ,LO,AZC,NDf
所需输出
2020-01-17 13:57:58,88823,aJ,MO,ZXC,adf
2020-01-17 13:58:38,78823,sJ,MO,AXC,Ldf
2020-01-17 13:59:18,98823,DJ,LO,AZC,NDf
如果有人能在这方面帮助我,那将非常有帮助。
问候阿米特
答案1
以下是根据您提供的 3 行输入猜测您想要的内容:
sed -e 's/\(^..........\)\(........\)/\1 \2,/g' in > out
或者,等效地:
sed -e 's/\(^.\{10\}\)\(.\{8\}\)/\1 \2,/g' in > out
答案2
脚本内容
#!/usr/bin/env python
txt = """
2020-01-1713:57:5888823,aJ,MO,ZXC,adf
2020-01-1713:58:3878823,sJ,MO,AXC,Ldf
2020-01-1713:59:1898823,DJ,LO,AZC,NDf
"""
for line in txt.splitlines():
print(line[:10], line[10:])
运行
# ./asdf
2020-01-17 13:57:5888823,aJ,MO,ZXC,adf
2020-01-17 13:58:3878823,sJ,MO,AXC,Ldf
2020-01-17 13:59:1898823,DJ,LO,AZC,NDf