Skip to content

Instantly share code, notes, and snippets.

@hansode
Created September 28, 2013 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansode/6738573 to your computer and use it in GitHub Desktop.
Save hansode/6738573 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# requires:
# bash
#
set -e
while read line; do
set ${line}
pid=$(echo ${line} | sed "s, ,\n,g" | head -1)
while [[ "${1}" ]]; do
case "${1}" in
-name)
shift
name=${1}
;;
-serial|-monitor)
key=${1##-}; shift
val=$(echo ${1} | awk -F, '{print $1}' | awk -F: '{print $3}')
eval ${key}=${val}
;;
*)
;;
esac
shift
done
echo name=${name} serial=${serial} monitor=${monitor} pid=${pid}
done < <(ps -e -o pid,command | grep '[/]usr/libexec/qemu-kvm')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment