Settings

Theme

Not all grep implementations provide an “-o” option

2 points by textmode 4 years ago · 1 comment · 1 min read


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"
zinekeller 4 years ago

It's not mandated by POSIX: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/g...

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection