Home » Tutorials » SH module for python

SH module for python

For python3 on arch to install python modules installer:

$ sudo pacman -S pip

To install the module:

$ pip install sh

then in python shell/script:

import sh

Then you can use it as follow:

sh.ls("-l", "/home/user")

You can as well iterate over it, for example:

for line in sh.grep("something", "/home/user/somefile"):
    print(line)
Posted in Tutorials, Useful and tagged as , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.