Skip to content
Advertisement

Linux, how to parsing for pci express NVMe?

I’m working on bash script getting the pci nvme address for hot reset.

I want to parsing for pci express nvme ADDRESS (i.e /sys/devices/pci0000:00/0000:00:01.2/0000:01:00.2/0000:02:00.0/0000:03:00.0/nvme/nvme0

how can i do this?

I want to parse the address value before nvme.

Advertisement

Answer

You can use cut with / as the delimiter.

addr='/sys/devices/pci0000:00/0000:00:01.2/0000:01:00.2/0000:02:00.0/0000:03:00.0/nvme/nvme0'
nvme=$(cut -d/ -f8 <<<"$addr")
echo "$nvme"
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement