I have a file which contains hardware information. For example
Part Number : 0-0000-00
Board Revision : 0
PCB Serial Number : ZKZHY5431ZG
PCB Fab Part Number : 0-0000-00
Deviation Number : 0
MAC Address : FC:58:9A:07:4F:D4
MAC Address Block Size : 4
PCA Assembly Number : 000-00000-00
PCA Revision Number : 0
Product/Model Number : IG21-EU-E-K9
Top Assembly Part Number : 074-123960-01
Top Revision Number : 02
Top Assembly Serial Number : PSZ24351JZG
RMA Test History : 00
RMA History : 00
PEP Product Identifier (PID) : IG21-EU-E-K9
PEP Version Identifier (VID) : V00
System Flags : 00
Controller Type : 0000
Host Controller Type : 0000
Mfr Service Date : 2020.12.28-47:59:59
I want to exclude
few lines while doing cat on hardware file. To achieve this I tried below command
cat hardware.txt | grep -Ev 'Part Number|Board Revision|PCB Fab Part Number|PCA Assembly Number|PCA Revision Number'
it works fine but there is one small problem. When I run this command it also exclude Top Assembly Part Number
. It is because Part Number
is hitting another line as well.
I even tried -w
option with grep but with that I didn't get any output on console. It looks like exact match will fail as we have some value for each field in the hardware file
can someone please help me . how can I avoid exclusion of Top Assembly Part Number
^
and$
inman grep
. – dirkt Sep 16 '21 at 07:37cat hardware.txt | grep -Ev '^Part Number|Board Revision|PCB Fab Part Number|PCA Assembly Number|PCA Revision Number'
– vivek Sep 16 '21 at 08:01^Part Number|Board Revision...
and^(Part Number|Board Revision...)
, and why the variant in the answer is better. – dirkt Sep 16 '21 at 10:26