【发布时间】:2018-04-29 11:42:04
【问题描述】:
我有一个文件 trial.txt 包含
This can stay
// but this
/ and this
// must go
I will be happy
删除前导#我在其他情况下使用的
os.system(" sed '/^#.*/d' trial.txt > start.txt ")
所以要删除 // 我用过
os.system(" sed '/^//.*/d' trial.txt > start.txt ")
但这会报错
sed: 1: "/^//.*/d": invalid command code /
有什么建议吗?最好使用 Python 还是 Linux?
【问题讨论】:
-
您可以使用
'^/.*'。得到那些应该去的人