LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-09-2009, 05:19 PM   #1
pobrika
Member
 
Registered: Jan 2008
Location: Bournemouth, UK
Distribution: Mint, #!, Fedora, Redhat, Centos
Posts: 70

Rep: Reputation: 18
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
Example 2
Code:
         
                Socket Designation: Socket 1 CPU 1
                Version: Intel Xeon
                Status: Populated, Enabled
               
                Socket Designation: Socket 2 CPU 2
                Version: Intel Xeon
                Status: Populated, Enabled
Thanks
 
Old 06-09-2009, 05:25 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Maybe something like
Code:
dmidecode | awk '/Socket Designation|Version|Status/' | sed '0~3G'

Last edited by colucix; 06-09-2009 at 05:28 PM.
 
Old 06-09-2009, 06:06 PM   #3
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Fedora, Centos, Manjaro
Posts: 317

Rep: Reputation: 70
man dmidecode

and check out all of the options
 
Old 06-09-2009, 08:31 PM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by colucix View Post
Maybe something like
Code:
dmidecode | awk '/Socket Designation|Version|Status/' | sed '0~3G'
this may get other "Status" or Version belonging to other sections as well.
 
Old 06-09-2009, 11:00 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by ghostdog74 View Post
this may get other "Status" or Version belonging to other sections as well.
This one?
Code:
dmidecode | awk '/Socket Designation:|Version:|Status:/' | sed '0~3G'
 
Old 06-09-2009, 11:18 PM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by colucix View Post
This one?
Code:
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:
as you can see, "Version:" also appears..
 
Old 06-10-2009, 02:36 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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).
 
Old 06-10-2009, 04:48 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
curious

egrep '^[[:space:]]*(Socket|Version:|Status: )'

stupid smiley
???
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl adding unwanted lines at EOF? ryedunn Programming 1 09-07-2006 09:35 AM
getting rid of extra blanks lines Serena Linux - Newbie 5 02-27-2006 02:09 AM
How to grep similar lines in bash? bruno buys Linux - Software 2 12-02-2005 11:56 PM
How do I get rid of unwanted programs Mathias Cervantes Fedora 2 10-23-2005 10:08 AM
Grep lines gsibble Linux - General 1 04-12-2004 01:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration