{"id":1852,"date":"2014-04-25T14:23:19","date_gmt":"2014-04-25T19:23:19","guid":{"rendered":"http:\/\/www.kickflop.net\/blog\/?p=1852"},"modified":"2014-04-25T14:31:44","modified_gmt":"2014-04-25T19:31:44","slug":"when-bare-tee-command-wont-suffice","status":"publish","type":"post","link":"https:\/\/www.kickflop.net\/blog\/2014\/04\/25\/when-bare-tee-command-wont-suffice\/","title":{"rendered":"When bare &#8216;tee | command&#8217; won&#8217;t suffice"},"content":{"rendered":"<p>In my 20 years of touching UNIX\/Linux, I&#8217;d never had a need for this until today. If you search around for common search terms like &#8216;stdout to screen and file&#8217;, you are likely only to get basic information on how to use the UNIX\/Linux tee command.<\/p>\n<p>However, <code>command | tee somefile.out<\/code> loses the exit code of <code>command<\/code> if you care about checking it.<\/p>\n<p>The <code>bash<\/code> solution provided by someone on my employer&#8217;s internal Linux mailing list is:<\/p>\n<pre>{ command; RESULT=$?; } | tee somefile.out<\/pre>\n<p>Though I also just learned that one can reference the <a href=\"http:\/\/www.tldp.org\/LDP\/abs\/html\/internalvariables.html\">PIPESTATUS<\/a> array instead.<\/p>\n<pre>command | tee somefile.out\r\nif [ $PIPESTATUS[0] -ne 0 ]; then\r\n    echo \"Error...\"\r\nfi<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In my 20 years of touching UNIX\/Linux, I&#8217;d never had a need for this until today. If you search around&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,35,11,48],"tags":[],"class_list":["post-1852","post","type-post","status-publish","format-standard","hentry","category-devops","category-linux","category-sysadmin","category-unixlinux"],"_links":{"self":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/1852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/comments?post=1852"}],"version-history":[{"count":8,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/1852\/revisions"}],"predecessor-version":[{"id":1860,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/1852\/revisions\/1860"}],"wp:attachment":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/media?parent=1852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/categories?post=1852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/tags?post=1852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}