https://gist.github.com/fourdollars/47424ed5ee05679f05c7
#!/bin/sh
PARTITIONS="/dev/mmcblk0p1 /dev/mmcblk1p1 /dev/nvm0n1p1 /dev/nvm0n2p1 \
/dev/sda1 /dev/sdb1"
DEVICES="/dev/sdb /dev/nvm0n2 /dev/nvm0n1 /dev/mmcblk0"
result=""
[...] # can not use PARTITIONS here
for partition in $PARTITIONS; do
[...]
done
[...] # can not use PARTITIONS here
# Expected result: /dev/sdb1 /dev/nvm0n2p1 /dev/nvm0n1p1 /dev/mmcblk0p1
echo $result
主要是要依照指定 DEVICES 順序找出符合的磁碟分割區