{"id":19,"date":"2012-04-17T08:02:00","date_gmt":"2012-04-17T08:02:00","guid":{"rendered":"http:\/\/anjo.pt\/wp\/keyword-oracle\/2012\/04\/17\/grep-lines-before-or-after-without-grep\/"},"modified":"2015-11-17T20:27:23","modified_gmt":"2015-11-17T19:27:23","slug":"grep-lines-before-or-after-without-grep","status":"publish","type":"post","link":"https:\/\/anjo.pt\/keyword-oracle\/2012\/04\/17\/grep-lines-before-or-after-without-grep\/","title":{"rendered":"Grep lines before or after without grep"},"content":{"rendered":"<p>Here a way I used in AIX, where there is a grep without the -A and -B options:<\/p>\n<pre>\nnawk 'c--&gt;0;$0~s{if(b)for(c=b+1;c&gt;1;c--)\n   print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' \n   b=2 a=0 s=\"ORA-\"  alert_us.log\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here a way I used in AIX, where there is a grep without the -A and -B options: nawk &#8216;c&#8211;&gt;0;$0~s{if(b)for(c=b+1;c&gt;1;c&#8211;) print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}&#8217; b=2 a=0 s=&#8221;ORA-&#8221; alert_us.log<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,6],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","category-aix","category-oracle","czr-hentry"],"_links":{"self":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":1,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":163,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/19\/revisions\/163"}],"wp:attachment":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}