0
# lshw -c network -businfo
Bus info          Device      Class          Description
========================================================
pci@0000:03:00.0  enp3s0      network        I210 Gigabit Network Connection
pci@0000:04:00.0  mec_test_1  network        I350 Gigabit Network Connection
pci@0000:04:00.1  mec_test_2  network        I350 Gigabit Network Connection
pci@0000:04:00.2  mec_test_3  network        I350 Gigabit Network Connection
pci@0000:04:00.3  mec_test_4  network        I350 Gigabit Network Connection
pci@0000:b5:00.0              network        Intel Corporation
pci@0000:b5:00.1              network        Intel Corporation
pci@0000:b5:00.2  mec_test_5  network        Intel Corporation
pci@0000:b5:00.3  enp181s0f3  network        Intel Corporation

If I want to pass Device is empty, how to do that? like

Bus info          Device      Class          Description
========================================================
pci@0000:03:00.0  enp3s0      network        I210 Gigabit Network Connection
pci@0000:04:00.0  mec_test_1  network        I350 Gigabit Network Connection
pci@0000:04:00.1  mec_test_2  network        I350 Gigabit Network Connection
pci@0000:04:00.2  mec_test_3  network        I350 Gigabit Network Connection
pci@0000:04:00.3  mec_test_4  network        I350 Gigabit Network Connection
pci@0000:b5:00.2  mec_test_5  network        Intel Corporation
pci@0000:b5:00.3  enp181s0f3  network        Intel Corporation

1 Answer 1

0

One simple way would be to ask grep to look for a non-space character in the 19th column:

lshw -c network -businfo | grep -E '^.{18}[^ ]'

The grep command is looking for pattern that's anchored to the beginning of the line; there follows 18 of any character, then something that's not a space.

Alternatively, if there's a TAB there instead of space, use the [:space:] class:

lshw -c network -businfo | grep -E '^.{18}[^[:space:]]'
4
  • if I want to pass I350, how to do that? {18} just get char not string
    – bohan Chen
    Jan 3, 2019 at 12:22
  • I don't know what I350 is, here.
    – Jeff Schaller
    Jan 3, 2019 at 12:37
  • By "pass I350" do you mean omit those lines, or include only those lines? In either case, I think it would be appropriate to Ask a new Question and refer back to this one as your starting point.
    – Jeff Schaller
    Jan 3, 2019 at 14:39
  • answer like this Bus info Device Class Description ======================================================== pci@0000:03:00.0 enp3s0 network I210 Gigabit Network Connection pci@0000:b5:00.2 mec_test_5 network Intel Corporation pci@0000:b5:00.3 enp181s0f3 network Intel Corporation
    – bohan Chen
    Jan 7, 2019 at 7:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .