list_fat.sh
490 Bytes
#!/bin/bash
# Outputs, separated by newlines, the list of FAT volumes present on this computer
for disk in $(cat /proc/partitions | awk -F " " '{print $NF}' | tail -n+3); do
HEADER=$(dd if="/dev/$disk" bs=1 skip=82 count=5 2> /dev/null)
if [[ $HEADER == "FAT32" ]]; then
echo $disk
else
HEADER=$(dd if="/dev/$disk" bs=1 skip=54 count=5 2> /dev/null)
if [[ $HEADER == "FAT16" || $HEADER == "FAT12" ]]; then
echo $disk
fi
fi
done