pip3 install sh
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import sh
print (sh.df ( "- h")) #df -h command
print (sh.echo("123456 abcde")) #echo 命令
print (sh.free("-m")) #free -m 命令
print (sh.fdisk ( "- l")) #fdisk -l command
sh.mkdir("-p","python_sh_test") #mkdir 命令
sh.touch("python_sh_test/py_test.txt") #touch 命令
print (sh.cat("python_sh_test/py_test.txt")) #cat 命令
print (sh.tail("-5","python_sh_test/py_test.txt")) #tail -n 命令
#print (sh.ls ( "- l")) #ls -l command
#print (sh.xargs (sh.ls ( "- l"))) #ls -l | xargs command (pipeline is ordered, the default from the inside out)
#print (sh.grep (sh.ls ( "- l"), "txt $")) #ls -l | grep txt $ command (pipeline is ordered, the default from the inside out)