{"id":513,"date":"2016-09-06T13:48:50","date_gmt":"2016-09-06T08:18:50","guid":{"rendered":"http:\/\/www.cyberaka.com\/?p=513"},"modified":"2016-09-06T13:49:06","modified_gmt":"2016-09-06T08:19:06","slug":"leveraging-tee-and-grep-for-filtering-program-outpu","status":"publish","type":"post","link":"https:\/\/www.cyberaka.com\/?p=513","title":{"rendered":"Leveraging Tee and Grep for filtering program output"},"content":{"rendered":"<p>I have a utility which compiles my UI code and minifies them. It works pretty well and doesn&#8217;t requires much supervision. Trouble starts if the code compilation fails and it gets ignored in the huge log file which is generated by this utility. I use the following approach to filter out errors and yet preserving the output of the utility program for any diagnostic in case of any error. <\/p>\n<p><code>.\/my_utility.sh | tee output.txt | grep error<\/code><\/p>\n<p>Basically what happens is that &#8220;my_utility.sh&#8221; generates a lot of output which is piped into the &#8220;tee&#8221; command which in turn dumps it into a text file named &#8220;output.txt&#8221; and then the same output is again piped into the &#8220;grep&#8221; command which looks for any error text in the output. If the error is found it is outputted on the console. <\/p>\n<p>So the end result is that in 99% cases I don&#8217;t see any output from the utility as I don&#8217;t want to see debug output. However the moment an error happens it gets flagged on console and I have the &#8220;output.txt&#8221; file to audit what went wrong and the root cause of the error.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a utility which compiles my UI code and minifies them. It works pretty well and doesn&#8217;t requires much supervision. Trouble starts if the code compilation fails and it gets ignored in the huge log file which is generated by this utility. I use the following approach to filter out errors and yet preserving [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,35,24],"tags":[],"class_list":["post-513","post","type-post","status-publish","format-standard","hentry","category-linux-os","category-mac-os","category-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=513"}],"version-history":[{"count":2,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/513\/revisions"}],"predecessor-version":[{"id":515,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=\/wp\/v2\/posts\/513\/revisions\/515"}],"wp:attachment":[{"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberaka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}