you can use sed search and replace to just print the match, you just have to put the pattern in parentheses, and then reference the match in the replace part with a \1
pwd | sed 's/.*\(pattern\).*/\1/'
the ugly part is that you have to escape the parentheses with backslashes.
There is probably a better way, but this is short, and works like a charm
I assume sed is starting to look for the pattern from the beginning of the
input stream. How can I make sure that just the first occurrence of the searched pattern is being printed?
Thanks ranjithpr, but as I stated in my very first comment. The grep version I am using doesn't provide me with an "o" option, otherwise I would have used it.
---------- Post updated at 10:14 AM ---------- Previous update was at 10:06 AM ----------