TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Not all grep implementations provide an “-o” option

2 pointsby textmodeover 3 years ago
For example, Plan9 grep.<p>Solution:<p><pre><code> #!&#x2F;bin&#x2F;sh # usage: $0 pattern &lt; file x=$(echo x|tr x &#x27;\34&#x27;); tr -d &#x27;\12&#x27;|sed &quot;s&#x2F;$x&#x2F;&#x2F;g;s&#x2F;$1&#x2F;$x&amp;$x&#x2F;g&quot;|tr $x &#x27;\12&#x27;|sed -n &quot;&#x2F;^$1&#x2F;p&quot;</code></pre>

1 comment

zinekellerover 3 years ago
It&#x27;s not mandated by POSIX: <a href="https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;utilities&#x2F;grep.html" rel="nofollow">https:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;utilities&#x2F;g...</a>