使用 AWK 获取 LVM 大小?

Dev*_*tor 3 linux regex awk lvm string

我需要找出 image 的 LVM 大小vm001。假设我有一个名为/dev/VGgroup/vm001. 现在使用lvdisplay我可以找出大小:

--- Logical volume ---
  LV Name                /dev/VGgroup/vm001
  VG Name                VGgroup
  LV UUID                i0aYKs-Hpfv-q64V-9Rqu-6Wrq-eV3C-pZzo0D
  LV Write Access        read/write
  LV Status              available
  # open                 2
  LV Size                25.00 GB
  Current LE             6400
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:41
Run Code Online (Sandbox Code Playgroud)

如何使用仅输出的脚本/命令找出 LV 大小25?我知道awk你可以水平地找到字符串,但不能垂直地(据我所知)。

编辑 有更多的逻辑卷,使用lvdisplay | awk '/LV Size/ { print $3 }'将输出所有大小(显然),我如何只获得我想要的卷的大小?(在这种情况下vm001)。

glg*_*lgl 5

lvs /dev/vg/lvname -o LV_SIZE --noheadings --units G --nosuffix
Run Code Online (Sandbox Code Playgroud)

您以有用的形式获得 LV 的大小。