Skip to content

Instantly share code, notes, and snippets.

@somian
Last active December 20, 2015 08:19
Show Gist options
  • Save somian/6099523 to your computer and use it in GitHub Desktop.
Save somian/6099523 to your computer and use it in GitHub Desktop.
Bash user function (typically executed from an interactive shell while doing system work or just stuff) on GNU-Linux. Point is see mounted disk devices neatly printed.
## earlier version was fubar
function diskmounts {
cat /proc/mounts | perl -nawl \
-e 'if ($F[0]=~ m{/dev/(loop[[:digit:]]+ | sd[a-z][[:digit:]]? | sr[[:digit:]]+) | UUID= | LABEL=}x) {' \
-e ' push @dp=>[@F[0,1]]' \
-e '} END {print for map { $_->[1] } sort {$a->[0] cmp $b->[0]} map { [$_->[0], join (qq[\t\t],@$_)] }@dp}'
}
@somian
Copy link
Author

somian commented Jul 28, 2013

Output looks like this:

/dev/sda1 /boot
/dev/sda4 /
/dev/sda5 /var
/dev/sdb1 /media/usb0
/dev/sdb5 /media/usb3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment