[Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

Chris Angelico rosuav at gmail.com
Wed Nov 7 07:37:54 EST 2018


On Wed, Nov 7, 2018 at 11:36 PM Qian Cai <cai at gmx.us> wrote:
>
> srinivasan <srinivasan.rns at gmail.com> 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?
> >
> >
> Perfect place to use sed instead of grep/cut.

... or to use subprocess.check_output() to run just the blkid command,
and then do the parsing in Python.

ChrisA



More information about the Python-list mailing list