我想把这个sed命令删除一个儿子文件中的最后一个逗号。Sed一个班轮不能在蟒蛇子过程中工作
sed -i -e '1h;1!H;$!d;${s/.*//;x};s/\(.*\),/\1 /' file.json"
当我在命令行中运行它,它工作正常。当我尝试作为一个子进程运行,因此它不起作用。
Popen("sed -e '1h;1!H;$!d;${s/.*//;x};s/\(.*\),/\1 /' file.json",shell=True).wait()
我在做什么错?
你试过' check_call([“sed”,“ - e”,r“1h; 1!H; $!d; $ {s /.*//; x}; s/\(。* \),/ \ 1/,“file.json”])'?为什么不直接使用python呢?这很简单,你知道。 –
为什么从sed中删除选项'-i'? – Cyrus
,因为我滑/编辑错误。我把它放回到我的答案中。 –