On 07/11/2018 11:31, srinivasan wrote: > Even after changing as per the below > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > or: > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > or: > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" > > Still my output is: > */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"* > > My expected output should be only: > *vfat* > > Could you guys please do the needful?
I would strongly suggest that you stop trying to use grep and cut from within the subprocess. Instead just process the lines with Python. Its clearer and more efficient. In this case it seems to be almost trivial: output = subprocess.... # run blkid shell command and read output for line in output: if line.endswith("vfat"): # do whatever you want to do with line. -- 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