How do I change some values obtained from the list to the values I want with a smart way?

Hi @jamestwebber,
Thanks for your advice and sorry for the late reply.

The information shown on the image all obtained in the path /sys/bus/pci/device/BDF_id/… as following picture to the MAC address.


So I was thinking maybe I can get the port index I want in the path.
But because of there is no any information can let me use for displaying as port index so I fail.

This solution is suitable for solving the problem of the images.
But if the port index I wanted is displayed as follow, this solution won’t work.

Onboard	   0
Onboard    1
Onboard    2
Onboard    3
SLOTA 	   0
SLOTA 	   1
SLOTA 	   2
SLOTA 	   3
SLOTA 	   4
SLOTA 	   5
SLOTA 	   6
SLOTA 	   7
SLOTB      0
SLOTB      1
SLOTB      2
SLOTB      3

I had change the way to modify the result in a file, if you are interested, please feel free to discuss it together.
https://discuss.python.org/t/how-do-i-change-the-values-to-values-i-wanted-line-by-line-in-a-file/55656
Thank you.