想保持 test.txt 文件中,每个 key 后边的冒号有且只有一个空格,应该怎么处理
# text.txt
a: 1 # 标准格式
b:2
c: 3
d:
1
HeiXiaoBai 2019-05-06 18:56:02 +08:00 1
sed "s/:[ ]*/: /" test.txt > test_sed.txt
|
2
css3 OP |
3
HeiXiaoBai 2019-05-06 19:11:26 +08:00
sed "s/:[ ]*/: /g" test.txt
|
5
ifaii 2019-05-06 19:32:08 +08:00
perl -pe 's/^(\S+?\:)( *)(.*)$/\1 \3/' test.txt > new_text.txt
测试文本 abc:[{"k1": "v1", "k2":"v2"}] xxxa:sd:asdasdas abc:[{"k1": "v1", "k2":"v2"}] abc: [{"k1": "v1", "k2": "v2"}] # asdasdasd asdd: ss |
6
css3 OP |