{"id":41205,"date":"2021-03-17T18:50:55","date_gmt":"2021-03-17T18:50:55","guid":{"rendered":"https:\/\/www.oracletutoring.ca\/blog\/?p=41205"},"modified":"2021-03-17T18:50:57","modified_gmt":"2021-03-17T18:50:57","slug":"liunix-grep-and-grep-e-part1","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/liunix-grep-and-grep-e-part1\/","title":{"rendered":"[Li|U]nix: grep and grep -E, part1"},"content":{"rendered":"\n<h2>Self-tutoring about Unix: the tutor continues about grep.<\/h2>\n<p>\nAfter reading my <a href=\"https:\/\/www.oracletutoring.ca\/blog\/linux-grep-part-0\/\">post from yesterday<\/a>, I was in disbelief. I even tried the command there several more times &#8211; it works every time.<\/p>\n<p>grep isn&#8217;t necessarily expected to support alternation &#8211; that is, the &#8220;or&#8221; operator, | (but grep -E does). Surprisingly, the system I experimented with yesterday indeed does support | with grep.<\/p>\n<p>So, what are some differences between grep and grep -E (on this system, anyway)? Well, one is that grep needs escape sequences to specify specific multiples. For instance, the regex ^[a-zA-Z]{0,5} might mean 0 to 5 letters at the front of a string. I can do that with grep, this way:<\/p>\n<p>grep &#8220;[a-zA-Z]\\{0,5\\}&#8221;<\/p>\n<p>but with grep -E, this way:<\/p>\n<p>grep -E &#8220;[a-zA-Z]{0,5}&#8221;<\/p>\n<p>Relating to grep, the option -E means &#8220;enhanced&#8221; or &#8220;extended&#8221; functionality.<\/p>\n<p>Source:<\/p>\n<p><a href=\"https:\/\/www.regular-expressions.info\/gnu.html#bre\">www.regular-expressions.info<\/a><\/p>\nJack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.\n\n","protected":false},"excerpt":{"rendered":"<p>Self-tutoring about Unix: the tutor continues about grep. After reading my post from yesterday, I was in disbelief. I even tried the command there several more times &#8211; it works every time. grep isn&#8217;t necessarily expected to support alternation &#8211; &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/liunix-grep-and-grep-e-part1\/\"> <span class=\"screen-reader-text\">[Li|U]nix: grep and grep -E, part1<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[637],"tags":[],"class_list":["post-41205","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=41205"}],"version-history":[{"count":6,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41205\/revisions"}],"predecessor-version":[{"id":41211,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41205\/revisions\/41211"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=41205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=41205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=41205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}