[Tutor] how to grep a word and make a dictionary from multiple lines.

Fosiul Alam fosiul at gmail.com
Mon Jan 4 17:29:01 EST 2016


Hi Expert,
I am learning python to do some system admin code, i am still in the
process of learning but I need a help on bellow code in urgent, i will be
really greatfull for any help

Basically i wanted like this :-

grep a line which has 1:0:0:129 , and get the LUN number(i.e
360060165656565634348a739e511) for this path

so the Dictionalry will be :

dict = {'360060165656565634348a739e511': '1:0:0:129',
'3600601323h42h2k323asdf33511': 1:0:2:98};


How can i do this ?

any help will be really appreciable.

cat file.txt

mpathdz (360060165656565634348a739e511) dm-134 DGC,VRAID
size=200G features='0' hwhandler='1 alua' wp=rw
|-+- policy='round-robin 0' prio=130 status=active
| |- 0:0:0:129 sddz  128:16   active ready running
| `- 1:0:0:129 sdwd  69:656   active ready running
`-+- policy='round-robin 0' prio=10 status=enabled
  |- 0:0:2:129 sdnd  70:496   active ready running
  `- 1:0:2:129 sdafg 68:864   active ready running
mpathcu (3600601323h42h2k323asdf33511) dm-103 DGC,VRAID
size=200G features='0' hwhandler='1 alua' wp=rw
|-+- policy='round-robin 0' prio=130 status=active
| |- 1:0:2:98  sdaeb 66:880   active ready running
| `- 0:0:2:98  sdly  69:256   active ready running
`-+- policy='round-robin 0' prio=10 status=enabled
  |- 0:0:0:98  sdcu  70:32    active ready running
  `- 1:0:0:98  sduy  67:672   active ready running
mpathbp (36003434343eere8b69e411) dm-36 DGC,RAID 5
size=100G features='0' hwhandler='1 alua' wp=rw
|-+- policy='round-robin 0' prio=130 status=active
| |- 0:0:0:68  sdbq  68:64    active ready running
| `- 1:0:0:68  sdtu  65:704   active ready running
`-+- policy='round-robin 0' prio=10 status=enabled
  |- 0:0:2:68  sdku  67:288   active ready running
  `- 1:0:2:68  sdacx 8:912    active ready running


More information about the Tutor mailing list