How to pass an asterisk to module “sh” in python?

心不动则不痛 提交于 2019-12-06 16:47:49

The answer is:

I forgot that asterisk processing is done by bash itself, not by "du". Which means: "sh" indeed behaves correcly and exactly as one should expect. It passes "/tmp/*" directly to "du" (but bash does not). That's what Padraic Cunningham tried to tell me.

Therefor the ONLY correct way to do what I'm trying to do is the way the user rmn described:

sh.du('-sx', sh.glob('/tmp/*'))

And this is exactly what the bash shell itself does when calling "du".

use sh.glob

sh.du('-sx', sh.glob('/tmp/*'))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!