LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
LinkBack Search this Thread
Old 07-01-2009, 08:12 PM   #1
mbjunior99
Member
 
Registered: Feb 2004
Posts: 34

Rep: Reputation: 15
Delete first line from a grep result


I'm trying to remove the first line of a grep result but I can't workout how to do it. So far I have the following:

hwinfo --bios | grep -i product | cut -d ":" -f2 | tr \"' ' | sed -e 's/\ //g'

That gets me the following result:

0000000000
FJNB1A2

All I want to retain is the second line. Is there anyway to do this?
 
Old 07-01-2009, 08:56 PM   #2
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: Fedora 11, 15 & CentOS
Posts: 244

Rep: Reputation: 54
try grepping out the first line

hwinfo --bios | grep -i product | cut -d ":" -f2 | tr \"' ' | sed -e 's/\ //g'|grep -v 00000
 
Old 07-01-2009, 09:25 PM   #3
mbjunior99
Member
 
Registered: Feb 2004
Posts: 34

Original Poster
Rep: Reputation: 15
Thanks david1941, I actually just managed to do it this way:

hwinfo --bios | grep -i product | cut -d ":" -f2 | tr \"' ' | sed -e 's/\ //g' | tail -n 1

I will keep that for next time though. Thanks again.
 
Old 07-01-2009, 10:20 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 10,447

Rep: Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622
Just include it in the sed;
... sed -e 's/\ //g;1d'
 
Old 07-01-2009, 11:39 PM   #5
mbjunior99
Member
 
Registered: Feb 2004
Posts: 34

Original Poster
Rep: Reputation: 15
Even better, thanks a lot.
 
Old 07-02-2009, 01:07 AM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 237Reputation: 237Reputation: 237
even better, do it in one command
Code:
# hwinfo --bios | awk -F":" '/Product/{gsub(/\"| */,"",$2);s=$2}END{print s}'
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grep result passed to variable cornish Programming 5 11-15-2007 05:05 PM
showing grep result without the whole line Dr_Death_UAE Linux - General 12 09-07-2006 06:12 AM
ps -ef | grep iptables gives no result ? markraem Linux - Networking 1 07-07-2004 05:28 AM
how to grep within a script, and test result? bobbyr Programming 4 01-13-2004 12:11 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM


All times are GMT -5. The time now is 09:26 PM.

Main Menu
 
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
Open Source Consulting | Domain Registration