-
Using GNU grep to output just the match(es) and not the entire line containing the match(es)
echo “hello there.” | grep -o “ello t” ello t The flag ‘o’ (not Zero) does the trick. From the man page: -o, –only-matching Show only the part of a matching line that matches PATTERN. I couldn’t find that flag as an option in the BSD Grep man page. So this might only be available…