i'm still learning python, bare me!
i have list looks this:
['2 19 2839475239874 hda']
i need extract hda end. however, hda may not last chunk, hda may not 3 letters (it 4 or 5, , include numbers); start letter 'h'.
after hda extracted, need insert chunk dd command. looks this:
dd if=/dev/zero of=/dev/hda bs=512 count=1
but if hda different each time run dd command, need way have 'hda' part of dd command changeable.
sorry if confusing, beginner , confused myself! i've tried using startswith extraction, can't past there!
simply so:
lst = ['2 19 2839475239874 hda'] # extracting device part dev = filter(lambda s: s[0] 'h', lst[0].split())[0] # inserting cmd = 'dd if=/dev/zero of=/dev/{0} bs=512 count=1'.format(dev)
you want check case don't have h-word in list though.
Comments
Post a Comment