LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-16-2007, 10:37 PM   #1
ahpin
Member
 
Registered: Oct 2003
Location: Malaysia
Distribution: Redhat, Mandrake 9.1, SuSE Linux
Posts: 32

Rep: Reputation: 15
awk/sed to grep the text


HOw can i use the awk/ sed command to captured only the text from the full command line below?

host104;level2;Active;2.6.15-7-smp;

output needed:
2.6.15-7-smp

Thanks
 
Old 10-16-2007, 10:43 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,747

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Quote:
host104;level2;Active;2.6.15-7-smp;
As far as awk is concerned, you have 4 fields delineated by semicolon. So, the awk command would specify the field seperator as semicolon, and print the fourth field ($4).
 
Old 10-17-2007, 12:13 AM   #3
ahpin
Member
 
Registered: Oct 2003
Location: Malaysia
Distribution: Redhat, Mandrake 9.1, SuSE Linux
Posts: 32

Original Poster
Rep: Reputation: 15
Nope..awk not able to show the correct result as it still showing the full line of command which shoign none in this case.
 
Old 10-17-2007, 12:34 AM   #4
ahpin
Member
 
Registered: Oct 2003
Location: Malaysia
Distribution: Redhat, Mandrake 9.1, SuSE Linux
Posts: 32

Original Poster
Rep: Reputation: 15
Get it by using the deliminator setting below.

awk -F';' '{print $4}'



Thanks...
 
  


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
[Grep,Awk,Sed]Parsing text between XML tags. ////// Programming 5 07-26-2011 11:54 AM
sed/awk/grep for multiple line data hotrodmacman Programming 8 10-18-2007 11:06 AM
Need to strip words from front of line. sed/awk/grep? joadoor Linux - Software 6 08-28-2006 04:39 AM
diffrence between grep, sed, awk and egrep Fond_of_Opensource Linux - Newbie 3 08-18-2006 08:15 AM
How can I awk/sed/grep the IPs from the maillog? abefroman Programming 7 03-09-2006 10:22 AM


All times are GMT -5. The time now is 09:21 AM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration