Discussion

Not all grep implementations provide an “-o” option

For example, Plan9 grep.

Solution:

       #!/bin/sh
       # usage: $0 pattern < file
       x=$(echo x|tr x '\34');
       tr -d '\12'|sed "s/$x//g;s/$1/$x&$x/g"|tr $x '\12'|sed -n "/^$1/p"
2 points textmode 4 years ago 1 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton