I am trying to get disk information from fdisk -loutput in linux.
fdisk -l | grep -E 'Disk /dev/sd.\:'
I get the following output.
Disk /dev/sde doesn't contain a valid partition table
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
but i want to get
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
I tried to do it
fdisk -l | grep -E 'Disk /dev/sd.\:' | grep -v "contain"
but I have no idea why grep does not ignore the line containing "contain".
source
share