On 06/11/2018 18:07, srinivasan wrote: > bash command in python using subprocess module, I ma seeing the below > * cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)*
In general you should try to do as little as possible using bash and subprocess. Especially try to avoid long pipelines since you are starting a new OS process for every element in the pipeline. That means, in your case, you are running 4 processes to get your result - Python, blkid, grep and cut Python is designed to do much of what the shell command can do almost as easily and much more efficiently (no new processes being started). In this case just execute the blkid bit in bash because its too difficult to replicate simply in Python. Then use Python to search for the TYPE lines and slice them to size. That will, in turn, simplify your command string and remove the issue of multiple quotes. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor