Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-14-2010, 09:14 AM   #1
Registered: Mar 2010
Posts: 71

Rep: Reputation: 16
question on grep

i need to get the Serial Number of my motherboard . i used dmidecode to get the serial number. but obviously i needed only the serial number and not the whole details. so i used grep to get only serial number but the problem is i get 3 occurences of "serial number " and only one of the occurences actually has the serial number with it.

this is the code that i used

sudo dmidecode|grep -i 'Serial Number'
and this is the output that i get

Serial Number:
Serial Number: WYWU54401953
Serial Number:

how do i get only that one occurence?

thanx in advance
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-14-2010, 09:29 AM   #2
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
dmidecode |grep "Base Board Information" -A 5 | grep "Serial Number" | awk '{print $3}'
2 members found this post helpful.
Old 03-14-2010, 09:36 AM   #3
Registered: Mar 2010
Posts: 71

Original Poster
Rep: Reputation: 16
thanx !it works


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
[SOLVED] grep question aihaike Programming 3 07-28-2009 01:43 PM
using grep (question) graziano1968 Linux - General 5 02-12-2009 04:53 AM
grep question sudz28 Linux - Newbie 4 01-21-2009 08:13 PM
grep question torrent478 Linux - Newbie 2 10-08-2008 07:50 PM
grep question djgerbavore Linux - Newbie 7 07-07-2004 08:11 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:26 AM.

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