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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-09-2009, 05:19 PM
|
#1
|
|
Member
Registered: Jan 2008
Location: Bournemouth, UK
Distribution: Mint, #!, Fedora, Redhat, Centos
Posts: 61
Rep:
|
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
|
|
|
|
06-09-2009, 05:25 PM
|
#2
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,896
|
Maybe something like
Code:
dmidecode | awk '/Socket Designation|Version|Status/' | sed '0~3G'
Last edited by colucix; 06-09-2009 at 05:28 PM.
|
|
|
|
06-09-2009, 06:06 PM
|
#3
|
|
Member
Registered: Oct 2008
Location: Brisbane Australia
Distribution: always back to Fedora
Posts: 239
Rep:
|
man dmidecode
and check out all of the options
|
|
|
|
06-09-2009, 08:31 PM
|
#4
|
|
Senior Member
Registered: Aug 2006
Posts: 2,695
|
Quote:
Originally Posted by colucix
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.
|
|
|
|
06-09-2009, 11:00 PM
|
#5
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,896
|
Quote:
Originally Posted by ghostdog74
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'
|
|
|
|
06-09-2009, 11:18 PM
|
#6
|
|
Senior Member
Registered: Aug 2006
Posts: 2,695
|
Quote:
Originally Posted by colucix
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..
|
|
|
|
06-10-2009, 02:36 AM
|
#7
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,896
|
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).
|
|
|
|
06-10-2009, 04:48 AM
|
#8
|
|
Senior Member
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,211
Rep: 
|
curious
egrep '^[[:space:]]*(Socket|Version:|Status: )'
stupid smiley
???
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:51 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|