I need to use a commandline that is suited to bash style, e.g.
diff x <(cat y 开发者_运维问答| tail +2)
However, sh -c of the above line gives an error, hence commands.getoutput of the above line fails. However, bash -c of the above does what I want to get done. Can somebody suggest how to make python use bash. I understand I can get it done using subprocess, but I have a lot of command lines that I have to process and I want to use only commands.getoutput.
Thanks.
You can do commands.getoutput("bash -c 'diff x <(tail +2 y)'")
, perhaps (note that cat
is unnecessary).
However: commands.getoutput('tail +2 y | diff x -')
doesn't require Bash.
精彩评论