Is it possible to search and print only the matched pattern from grep. The default action is to print the whole line.

link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

Yes. Use the -o option, e.g.,

$ echo 'hello wide world' | grep -o wide
wide
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.