when I'm configuring grub2 to unlock an LVM root (rd.luks.name=UUID=cryptroot
) I usually just blkid /dev/nvme0n1p3 >> uuid
, edit the text and delete all the data that isn't the UUID, and then :r uuid
to insert it to the grub config in vim. I know there has to be an easier way to do this with sed
but so far the closest I've gotten is as follows:
➜ ~ blkid /dev/nvme0n1p3
/dev/nvme0n1p3: UUID="2276de2b-9370-4577-90ea-3b0191ebea4e"
TYPE="crypto_LUKS" PARTUUID="b7a643ce-8bca-418f-a631-b0fc8648432c"
➜ ~ blkid /dev/nvme0n1p3 | sed 's/.*UUID="\(.*\)" .*/\1/'
2276de2b-9370-4577-90ea-3b0191ebea4e" TYPE="crypto_LUKS
Anyone have any idea what I could add to the sed arguments to get rid of everything after the end of the UUID including that quotation mark?