分裂我有這樣一個字符串,命名爲選項字符串中的一個選項:找到空間在bash
"printer-is-accepting-jobs=true printer-is-shared=false printer-location=Library printer-make-and-model='HP LaserJet 600 M601 M602 M603' printer-state=3"
他們是「選項=值」的格式,用空格隔開。但「打印機型號和模型」具有空間價值。
試圖命令:
for word in $Options; do echo $word; done
所有的HP LaserJet M601 600 M602 M603是splited。
如何在bash命令中處理這個問題?
也許這裏的答案將解決你的問題http://stackoverflow.com/questions/9084257/bash-array-with-spaces-in-elements – clancer
確切地說,你想要什麼? – higuaro
@ h3nr1x。我想將字符串拆分爲數組,每行的option = value。 – user3085367