Device1 name and corresponding serial number:
lsblk --nodeps -o name,serial
Output:
NAME SERIAL
sda 0000000012400917BA30
sdb 0000000012400917BA96
Add -n if you don't want to print the header line:
lsblk --nodeps -no name,serial
Output:
sda 0000000012400917BA30
sdb 0000000012400917BA96
Pass the device as an argument to get only the serial number of a specific device:
lsblk --nodeps -no serial /dev/sda
Output:
0000000012400917BA30
Keep in mind lsblk lists information about all available (or the specified) block devices. Now, for those who do not know what that last term means:
In general, block devices are devices that store or hold data. Diskette drives, hard drives and CD-ROM drives are all block devices. But that's not a problem when using lsblk as you can simply add more columns, e.g., type (device type) and/or tran (device transport type), etc.:
lsblk --nodeps -no name,serial,type,tran
.
sda 0000000012400917BA30 disk sata
sdb 0000000012400917BA96 disk sata
sr0 4B583242334C453233353320 rom usb