How do I get rid of unwanted lines without grep -v in BASH
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How do I get rid of unwanted lines without grep -v in BASH
Hi,
I would like to know how I can get the ouput from the following dmidecode command in example 1 to look like example 2 without having to grep -v all the unwanted lines.
Is there a way in awk or sed?
Example 1
Code:
Processor Information
Socket Designation: Socket 1 CPU 1
Type: Central Processor
Family: Xeon
Manufacturer: GenuineIntel
ID: 24 0F 00 00 01 03 00 00
Signature: Type 0, Family F, Model 2, Stepping 4
Flags:
FPU (Floating-point unit on-chip)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
Version: Intel Xeon
Voltage: 1.5 V
External Clock: 100 MHz
Max Speed: 2800 MHz
Current Speed: 2000 MHz
Status: Populated, Enabled
Upgrade: ZIF Socket
L1 Cache Handle: 0x0004
L2 Cache Handle: 0x0005
L3 Cache Handle: Not Provided
Handle 0x0009
DMI type 4, 32 bytes.
Processor Information
Socket Designation: Socket 2 CPU 2
Type: Central Processor
Family: Xeon
Manufacturer: GenuineIntel
ID: 24 0F 00 00 01 03 00 00
Signature: Type 0, Family F, Model 2, Stepping 4
Flags:
FPU (Floating-point unit on-chip)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
Version: Intel Xeon
Voltage: 1.5 V
External Clock: 100 MHz
Max Speed: 2800 MHz
Current Speed: 2000 MHz
Status: Populated, Enabled
Upgrade: ZIF Socket
L1 Cache Handle: 0x0006
L2 Cache Handle: 0x0007
L3 Cache Handle: Not Provided
dmidecode | awk '/Socket Designation:|Version:|Status:/' | sed '0~3G'
well, according to what OP is desiring, getting the exact "Version:" and "Status:" from the "processor information" block should be the way to go. therefore a little more coding to find where the "processor information" block is, then get the relevant "Version" and "Status" . here's one extract from my end under Bios information
Code:
BIOS Information
Vendor: Lenovo
Version: v1.11
Release Date: 10/14/06
Address: 0xE7C40
Runtime Size: 99264 bytes
ROM Size: 1024 kB
Characteristics:
You're right (as always) but the OP can always handle it using the -t option of dmidecode to extract just the relevant information (dmidecode -t processor).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.