<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2"><br><br>Andrew Jeffery <<a target="_blank" href="mailto:andrew@aj.id.au">andrew@aj.id.au</a>> wrote:<br>>On Tue, 2016-02-23 at 23:36 +0000, Milton Miller II wrote:<br>>> Around 02/23/2016 05:02PM in some time zone, Joel Stanley wrote:<br>>> >On Wed, Feb 24, 2016 at 1:15 AM, Andrew Jeffery <<a target="_blank" href="mailto:andrew@aj.id.au">andrew@aj.id.au</a>><br>>> >wrote:<br>>> >> Busybox's blkid is a little hamstrung, requiring some processing<br>>> >> of the<br>>> >> output to emulate what can be achieved with a couple of options<br>>> >> with<br>>> >> blkid from util-linux.<br><br>...<br><br>>> But more awk less pipes!<br>>> <br>>> - blkid $1 \<br>>> - | tr ' ' '\n' \<br>>> - | awk -F= '/TYPE/ { print $2 }' \<br>>> - | tr -d '"'<br>>> + blkid $1 | awk ' { if (match($0, / TYPE="[^"]*"/)) {<br>>> + print substr ($0, RSTART+7,<br>>RLENGTH-8);<br>>> + exit 0; }<br>>> + }'<br>><br>>IMO this alternative is less readable: I find it relatively harder to<br>>parse the regex (with character classes and repetition operators) and<br>>then perform substring indexing, than to follow the pipeline of<br>>substitutions and a straight text match. Horses for courses? Less<br>>pipes<br>>means less subprocesses but do we really care here?<br>><br><br>Yea, I wasn't totallly happy with the result. But sub is messy in awk <br>compared to sed. We need to kill everything before our requested <br>field and everything after its final quote:<br><br>blkid /dev/mtdblock6 | sed -e 's/^.*TYPE="//' -e 's/".*$//'<br><br>And it provdes the expected output if you change TYPE to UUID.<br><br>milton<br></font><BR>