echo -e "Size\tFiles\tDirectory";
paste <(du -sh ./*/ | sort -k2 | cut -f1) <(find ./*/ | cut -d/ -f2 | uniq -c | sort -k2 | awk '{print ($1-1)"\t"$2}') | sort -nk2
我需要在python代码中输出上面的shell脚本。
有没有办法通过python代码获取相同的输出或在python代码中插入上面的脚本。
此外,我需要插入变量代替路径./*/,即我的路径是变量,例如x = / usr / bin。
答案 0 :(得分:0)
使用可以使用pthon中的subprocess,easyprocess等库 它可以在pythons中运行命令并将输出作为stdout