LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   extract part of a line with sed or awk (https://www.linuxquestions.org/questions/linux-newbie-8/extract-part-of-a-line-with-sed-or-awk-673650/)

alirezan1 10-01-2008 08:55 PM

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

ghostdog74 10-01-2008 09:06 PM

Code:

sed 's/.*st:\(.*\)ds.*/\1/'

alirezan1 10-01-2008 09:44 PM

Quote:

Originally Posted by ghostdog74 (Post 3297569)
Code:

sed 's/.*st:\(.*\)ds.*/\1/'

thanks alot!


All times are GMT -5. The time now is 12:32 AM.