I have an issue with part of a script that is attempting to check if an attached volume is formatted before formatting.
The grep used in this check returns zero when the volume isnt formatted when using nvme volumes. This because the output of file -s seems to be a long string of characters:
Xs\333d8\374R\352if\253w}$\014\246E\034_I\275\304\2505!\3536U\336\252\274\252\323K\345\334\225;\356\0075T\350ru\003Kwp\353v:\326\263a\251\307\/\001Db\216
Due to this the grep count returns zero and the script assumes the disk is already formatted because an if statement assumes if the count is zero it must be formatted already.
The current check is on the output of whether this is zero:
file -s /dev/nvme | grep -c ': data$'
I would like to know if I can use blkid safely but check to make sure its greater than zero instead of zero to determine if the volume is formatted:
blkid | grep -c /dev/nvme