<p>I'm looking for a little shell script that will take anything piped into it, and dump it to a file.. for email debugging purposes. Any ideas?</p>

[{'answer_id': 76719, 'author': 'JBB', 'author_id': 12332, 'author_profile': 'https://Stackoverflow.com/users/12332', 'pm_score': 2, 'selected': False, 'text': '<p>Use Procmail. Procmail is your friend. Procmail is made for this sort of thing.</p>\n'}, {'answer_id': 76721, 'author': 'Stephen Deken', 'author_id': 7154, 'author_profile': 'https://Stackoverflow.com/users/7154', 'pm_score': 6, 'selected': True, 'text': '<p>The unix command tee does this.</p>\n\n<pre><code>man tee\n</code></pre>\n'}, {'answer_id': 76731, 'author': 'Commodore Jaeger', 'author_id': 4659, 'author_profile': 'https://Stackoverflow.com/users/4659', 'pm_score': 4, 'selected': False, 'text': '<pre><code>cat &gt; FILENAME\n</code></pre>\n'}, {'answer_id': 76735, 'author': 'Brian Mitchell', 'author_id': 13716, 'author_profile': 'https://Stackoverflow.com/users/13716', 'pm_score': 3, 'selected': False, 'text': '<p>The standard unix tool tee can do this. It copies input to output, while also logging it to a file.</p>\n'}, {'answer_id': 76736, 'author': 'Isak Savo', 'author_id': 8521, 'author_profile': 'https://Stackoverflow.com/users/8521', 'pm_score': 3, 'selected': False, 'text': '<p>You\'re not alone in needing something similar... in fact, someone wanted that functionality decades ago and developed <a href="http://linux.die.net/man/1/tee" rel="nofollow noreferrer">tee</a> :-)</p>\n\n<p>Of course, you can redirect stdout directly to a file in any shell using the > character:</p>\n\n<pre><code>echo "hello, world!" &gt; the-file.txt\n</code></pre>\n'}, {'answer_id': 76741, 'author': 'Mo.', 'author_id': 1870, 'author_profile': 'https://Stackoverflow.com/users/1870', 'pm_score': 0, 'selected': False, 'text': '<p>Huh? I guess, I don\'t get the question?</p>\n\n<p>Can\'t you just end your pipe into a <code>&gt;&gt; ~file</code></p>\n\n<p>For example</p>\n\n<pre><code>echo "Foobar" &gt;&gt; /home/mo/dumpfile\n</code></pre>\n\n<p>will append Foobar to the dumpfile (and create dumpfile if necessary). No need for a shell script... Is that what you were looking for?</p>\n'}, {'answer_id': 76742, 'author': 'terminus', 'author_id': 9232, 'author_profile': 'https://Stackoverflow.com/users/9232', 'pm_score': 1, 'selected': False, 'text': "<p>If you want to analyze it in the script:</p>\n\n<pre><code>while /bin/true; do\n    read LINE\n    echo $LINE &gt; $OUTPUT\ndone\n</code></pre>\n\n<p>But you can simply use cat. If cat gets something on the stdin, it will echo it to the stdout, so you'll have to pipe it to cat >$OUTPUT. These will do the same. The second works for binary data also.</p>\n"}, {'answer_id': 76748, 'author': 'BCS', 'author_id': 1343, 'author_profile': 'https://Stackoverflow.com/users/1343', 'pm_score': 0, 'selected': False, 'text': "<p>if you don't care about outputting the result</p>\n\n<pre><code>cat - &gt; filename\n</code></pre>\n\n<p>or</p>\n\n<pre><code>cat &gt; filename\n</code></pre>\n"}, {'answer_id': 76754, 'author': 'sirprize', 'author_id': 12902, 'author_profile': 'https://Stackoverflow.com/users/12902', 'pm_score': 1, 'selected': False, 'text': '<p>If you want a shell script, try this:</p>\n\n<pre><code>#!/bin/sh\nexec cat &gt;/path/to/file\n</code></pre>\n'}, {'answer_id': 76763, 'author': 'Liudvikas Bukys', 'author_id': 5845, 'author_profile': 'https://Stackoverflow.com/users/5845', 'pm_score': 1, 'selected': False, 'text': "<p>If exim or sendmail is what's writing into the pipe, then procmail is a good answer because it'll give you file locking/serialization and you can put it all in the same file.</p>\n\n<p>If you just want to write into a file, then\n  - tee > /tmp/log.$$\nor\n  - cat > /tmp/log.$$\nmight be good enough.</p>\n"}, {'answer_id': 78515, 'author': 'Scott', 'author_id': 7399, 'author_profile': 'https://Stackoverflow.com/users/7399', 'pm_score': 1, 'selected': False, 'text': '<p>Use <code>&lt;&lt;command&gt;&gt; | tee &lt;&lt;file&gt;&gt;</code> for piping a command <code>&lt;&lt;command&gt;&gt;</code> into a file <code>&lt;&lt;file&gt;&gt;</code>. </p>\n\n<p>This will also show the output.</p>\n'}]
['https://Stackoverflow.com/questions/76700', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12624/']