Python OS和Grep的子过程
我正在尝试执行:GREP -A5000 -M1 -E'DOG 123 4335'AIMATER.TXT在Python脚本中。
输入文件:
cat 13123 23424
deer 2131 213132
bear 2313 21313
dog 123 4335
cat 13123 23424
deer 2131 213132
bear 2313 21313
输出:
cat 13123 23424
deer 2131 213132
bear 2313 21313
我在unix中尝试了此命令,它可以正常工作。但是,它没有使用Python OS.System或子过程执行。请给我任何一个解决方案。
I'm trying to execute: grep -A5000 -m1 -e 'dog 123 4335' animals.txt in python script.
Input file:
cat 13123 23424
deer 2131 213132
bear 2313 21313
dog 123 4335
cat 13123 23424
deer 2131 213132
bear 2313 21313
Output:
cat 13123 23424
deer 2131 213132
bear 2313 21313
I tried this command in Unix it works fine. But it's not getting executed using python the OS.system or the subprocess. Please give me the solution for either one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
子过程
:输出:
Use
subprocess
:Output: