how to print the disks from lsblk in GIGA


dm-0  lvm     50G
dm-1  lvm     16G
dm-2  lvm    100G
sdb   disk   1.8T AVAGO
sdc   disk   1.8T AVAGO
sdd   disk   1.8T AVAGO
sde   disk   1.8T AVAGO

we need to print all disks in GIGA

we have the option -b to print in byte but we prefer in giga

  • 2
    What is GIGA? Do you mean gigabytes? Gigabit? Is that the same as giga? – Anthon Oct 2 '17 at 9:37

Try this:

lsblk -b -io KNAME,TYPE,SIZE,MODEL | awk 'BEGIN{OFS="\t"} {if (FNR>1) print $1,$2,$3/1073741824"G",$4; else print $0}'

Not the answer you're looking for? Browse other questions tagged or ask your own question.