{"id":6092,"date":"2014-03-25T07:21:00","date_gmt":"2014-03-25T07:21:00","guid":{"rendered":""},"modified":"2026-04-18T22:43:24","modified_gmt":"2026-04-18T22:43:24","slug":"using-grep-to-match-lines-not-containing-a-word","status":"publish","type":"post","link":"https:\/\/hellem.org\/wblog\/?p=6092","title":{"rendered":"Using grep to match lines not containing a word"},"content":{"rendered":"<p>My case was: Match all lines with key purgepolicy, but not containing the word Entirepool<\/p>\n<p><!-- codeblock lang= line=1 --><\/p>\n<pre class=\"codeblock\"><code>\r\npurgePolicy=EntirePool\r\npurgePolicy=FailingConnectionOnly\r\n<\/code><\/pre>\n<p><!-- \/codeblock --><\/p>\n<p>First I tried to use the ! operator in the regex, but that only causes the error <\/p>\n<p><code class=\"codespan\">bash: !\": event not found<\/code><\/p>\n<p>Solution was to first find all lines with purgepolicy then pipe the result and exclude all results with EntirePool<\/p>\n<p><code class=\"codespan\">grep \"purgePolicy=\" myfile.props | grep -v \"EntirePool\"<\/code><\/p>\n<p>Solution found at http:\/\/www.thegeekstuff.com\/2011\/10\/grep-or-and-not-operators\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My case was: Match all lines with key purgepolicy, but not containing the word Entirepool purgePolicy=EntirePool purgePolicy=FailingConnectionOnly First I tried to use the ! operator in the regex, but that only causes the error bash: !&#8221;: event not found Solution was to first find all lines with purgepolicy then pipe the result and exclude all [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"class_list":["post-6092","post","type-post","status-publish","format-standard","hentry","category-work-geek"],"_links":{"self":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/6092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6092"}],"version-history":[{"count":1,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/6092\/revisions"}],"predecessor-version":[{"id":11512,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/6092\/revisions\/11512"}],"wp:attachment":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}