LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 06:19 PM   #1
pobrika
Member
 
Registered: Jan 2008
Location: Bournemouth, UK
Distribution: Mint, #!, Fedora, Redhat, Centos
Posts: 64

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, 06:25 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

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

Last edited by colucix; 06-09-2009 at 06:28 PM.
 
Old 06-09-2009, 07:06 PM   #3
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: always back to Fedora
Posts: 241

Rep: Reputation: 50
man dmidecode

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

Rep: Reputation: 241Reputation: 241Reputation: 241
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-10-2009, 12:00 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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-10-2009, 12:18 AM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
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, 03:36 AM   #7
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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, 05:48 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
curious

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

stupid smiley
???
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:35 AM
getting rid of extra blanks lines Serena Linux - Newbie 5 02-27-2006 03:09 AM
How to grep similar lines in bash? bruno buys Linux - Software 2 12-03-2005 12:56 AM
How do I get rid of unwanted programs Mathias Cervantes Fedora 2 10-23-2005 11:08 AM
Grep lines gsibble Linux - General 1 04-12-2004 02:30 AM


All times are GMT -5. The time now is 10:16 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration