On 11/12/2014 01:33 AM, Max Reitz wrote: >>> + -e 's#^{"QMP":.*}$#QMP_VERSION#' \ >>> + -e 's#\\#\\\\#g' | \ >>> + while IFS='' read line; do >>> + if [[ $line == ' "QMP": {' ]]; then >> Good that this is a /bin/bash script and not /bin/sh :) > > Ah, right, yes, I just copied the code I had written for filtering out > the image-specific information from the qemu-img info output. > >> But - is it really worth doing this in shell? Why not just do it in sed? > > Because I don't know sed well enough. ;-) > >> sed -e ... \ >> -e 's#\\#\\\\#g' \ >> -e '/ "QMP": {/,/ }/ c\' \ Better make this line anchored in its searching: -e '/^ "QMP": {$/,/^ }$/ c\' \ >> -e ' QMP_VERSION' > > Will do, thanks. > > Max > > -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org