我有一根绳子。其中一部分包含"Log":true.,我想使用bash和sed删除它。
原线
[...]\"Date\":\"1661731200000\",\"Log\":true,\"$$type\":\"system\",\"created\":\"2022-08-01T13:37:43+0[...]修正线
[...]\"Date\":\"1661731200000\",\"$$type\":\"system\",\"created\":\"2022-08-01T13:37:43+0[...]我很难找到正确的表达方式。是否有可能用sed实现它?
发布于 2022-08-15 15:42:09
匹配,\"Log\":,后面跟着任何字母字符序列。
sed 's/,\"Log\":[a-z]*//' filename发布于 2022-08-15 16:48:06
#!/bin/sh
cat << EOF >> edpop
2d
wq
EOF
cat file | tr ',' '\n' > file2
ed -s file2 < edpop
cat file2 | tr '\n' ',' > file
rm -v ./file2
rm -v ./edpop这将用新行替换逗号,用ed删除第二行(对应于第二个逗号字段),然后再用逗号替换换行符。
https://stackoverflow.com/questions/73363250
复制相似问题