write-image-to-disk/scripts/list-disks.sh
Eliezer Croitoru b5c7f1fdc4 1
2023-12-23 18:01:43 +00:00

16 lines
425 B
Bash

#!/usr/bin/env bash
disk=()
size=()
name=()
while IFS= read -r -d $'\0' device; do
device=${device/\/dev\//}
disk+=($device)
name+=("`cat "/sys/class/block/$device/device/model"`")
size+=("`cat "/sys/class/block/$device/size"`")
done < <(find "/dev/" -regex '/dev/sd[a-z]\|/dev/vd[a-z]\|/dev/hd[a-z]' -print0)
for i in `seq 0 $((${#disk[@]}-1))`; do
echo -e "${disk[$i]}\t${name[$i]}\t${size[$i]}"
done