J. Milgram incurred the wrath of Bob on Jan 4, by saying

>[sorry to mix unrelated topics here...]
>
>First, is there a cleaner way to get a partition type id than:
>
>fdisk -l $DEVICE | grep $PARTITION | awk '{print $5}'
>
>???

How about....

fdisk -l $DEVICE | awk /${PARTITION//\//\\\/}/' {print $5}'

which gets one process out of the pipeline

???

Yes, I'm still here, and still useless.

Slightly (/very/ slightly) more useful: neither of the above will work
if the partition in question has the boot flag set, because that creates
its own field, so the ID will be in column 6 instead of 5.  Maybe:

fdisk -l $DEVICE | grep $PARTITION | cut -c 53-54

...but this alone will print a leading space for single-digit IDs, which
may not be what you want (and I don't know if the exact character width
of the fdisk output is reliable).

Since checking for disk formats isn't usually something that's put in a
crontab, it's hard to imagine someone has made a tool to do this the
"right" way (and that said tool has become popular enough to be easily
found).  I'm often wrong, though.

-- 
Cheers,
Bob Schmertz

Reply via email to