If you are looking for the UUID of the device mounted as
/boot on a running system, a clean way is
$ findmnt --output=UUID --noheadings --target=/boot
With these self-explanatory options it outputs the UUID only. It also saves you the hassle of figuring out which device is the relevant one.
If you are just looking for the UUID of a device you know of, regardless of whether it is mounted or not, you can use
blkid, as mentioned in Andy Dalton's answer:
$ sudo blkid -s UUID -o value /dev/vda1
-s tag and
-o format options restrict the output to the value of the UUID tag only.
You can then append the UUID to
GRUB_CMDLINE_LINUX with a command as:
sed -i.bkp 's/^\([[:blank:]]*GRUB_CMDLINE_LINUX=".*\)\(".*\)$/\1 fips=1 boot=UUID='"$newuuid"'\2/' /etc/default/grub
Which assumes the
-i option's syntax of GNU
sed: it will edit the file in-place, also creating a
grub.bkp backup file.
Note that we are not checking if a
boot command line parameter is already there; we are just appending
newuuid before the second
", thus assuming your current command line is enclosed in double quotes and does not contain any double quote.