Skip to content

Instantly share code, notes, and snippets.

@jcordeiro
Created June 15, 2013 01:48
Show Gist options
  • Save jcordeiro/5786445 to your computer and use it in GitHub Desktop.
Save jcordeiro/5786445 to your computer and use it in GitHub Desktop.
Just a small shell file I had to write for my OS class that goes through the first 4 disks on a linux system and prints out the number of partitions they have.
#!/bin/bash
echo "The following hard disks are currently present in your system:"
for DISK in /dev/sda /dev/sdb /dev/sdc /dev/sdd
do
echo "The disk $DISK appears to have `fdisk -l $DISK 2> /dev/null | grep -E $DISK\[0-9]\ | wc -l` partitions."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment