Skip to content

Instantly share code, notes, and snippets.

@JackieKu
Created April 1, 2012 16:46
Show Gist options
  • Save JackieKu/2276961 to your computer and use it in GitHub Desktop.
Save JackieKu/2276961 to your computer and use it in GitHub Desktop.
#!/bin/bash
sfdisk -l "$@" |
if [[ " $* " == *' -uB '* ]] || [[ " $* " == *' -uS '* ]] ; then
sed -rn "\#^$1#"'{s#^\S+\s+([* ])\s+([0-9]+)[+\-]?\s+([0-9]*)[+\-]?\s+([0-9]+)[+\-]?\s+([0-9a-f]+)\s.*$#\2,\4,\5,\1#;p}'
else
sed -rn "\#^$1#"'{s#^\S+\s+([* ])\s+([0-9]+)[+\-]?\s+([0-9]*)[+\-]?\s+([0-9]+)[+\-]?\s+([0-9]+)[+\-]?\s+([0-9a-f]+)\s.*$#\2,\4,\6,\1#;p}'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment