LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices



Reply
 
Search this Thread
Old 10-01-2008, 09:55 PM   #1
alirezan1
Member
 
Registered: Nov 2004
Location: Vancouver
Distribution: Ubunty, CentOS ,Mandriva, Gentoo, RedHat, Fedora, Knoppix
Posts: 147

Rep: Reputation: 15
extract part of a line with sed or awk


Hi all,

I want to extract a part of a line which comes between "ds:" and "st:" in output of a /proc/... file.

I used awk and sed and tried many ways similar to what was suggested on this forum in other threads but no luck. Here's how the part of file I want to extract looks like:

0: cs:WFConnection st:Unknown/Unknown ds:Inconsistent/DUnknown C r---

I want to extract "Unkonwn/Unknown" part. Can someone please help me out here?

Thanks
 
Old 10-01-2008, 10:06 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Code:
sed 's/.*st:\(.*\)ds.*/\1/'
 
Old 10-01-2008, 10:44 PM   #3
alirezan1
Member
 
Registered: Nov 2004
Location: Vancouver
Distribution: Ubunty, CentOS ,Mandriva, Gentoo, RedHat, Fedora, Knoppix
Posts: 147

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ghostdog74 View Post
Code:
sed 's/.*st:\(.*\)ds.*/\1/'
thanks alot!
 
  


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
Sed and printing only part of a line jrdioko Linux - Software 12 05-17-2012 08:15 PM
Problem changing line with sed. Should i use AWK? RattleSn@ke Linux - General 7 11-12-2007 02:03 PM
sed/awk/grep for multiple line data hotrodmacman Programming 8 10-18-2007 12:06 PM
sed to extract multiple matches in a line? mhoch3 Linux - Software 8 08-01-2005 04:32 PM
How to extract a part of a line by sed? J_Szucs Programming 2 02-15-2003 07:49 PM


All times are GMT -5. The time now is 12:35 PM.

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