document.write('<div class="bash" style="font-family: monospace;"><br />');
document.write('<span style="color: #808080; font-style: italic;">#!/bin/sh</span><br />');
document.write('<span style="color: #808080; font-style: italic;"># Count lines of C, C++, Java, or C# code, excluding comments and blank lines.</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#</span><br />');
document.write('<span style="color: #808080; font-style: italic;"># Originally obtained from:</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp;http://www.cs.cornell.edu/courses/cs114/2004fa/notes/lec8.html, 2004-10-15</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#</span><br />');
document.write('<span style="color: #808080; font-style: italic;"># 2006-09-14: Ken Stanley</span><br />');
document.write('<span style="color: #808080; font-style: italic;"># 1. Modified the code to print out a comparison of lines between the commented</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; code and then the code if the comments were to be removed.</span><br />');
document.write('<span style="color: #808080; font-style: italic;"># 2. Now it will exclude all comments that start with a #, except if the</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; comment happens to be something like &quot;#!/bin/sh&quot; which is not a comment.</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#</span><br />');
document.write('<br />');
document.write('<span style="color: #000066;">echo</span> -en <span style="color: #ff0000;">&quot;Including comments:<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>;<br />');
document.write('<span style="color: #0000ff;">WITHCOMMENTS=</span>`cat $* | wc -l`;<br />');
document.write('<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;$WITHCOMMENTS&quot;</span>;<br />');
document.write('<br />');
document.write('<span style="color: #808080; font-style: italic;"># Order of operation:</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp;1. Strip C++ // comments</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp;2. Replace @ and % with + and newline with @</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp;3. Replace */ with %</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp;4. Strip /* ... %</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp;5. Restore newlines</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp;6. Strip blank lines: [] contains a tab and space</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp;7. Strip all bash-style comments</span><br />');
document.write('<span style="color: #808080; font-style: italic;">#&nbsp; &nbsp; &nbsp; &nbsp;8. Count the remaining lines</span><br />');
document.write('<span style="color: #000066;">echo</span> -en <span style="color: #ff0000;">&quot;Without comments:<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>;<br />');
document.write('<span style="color: #0000ff;">WITHOUTCOMMENTS=</span>`sed -e <span style="color: #ff0000;">\'s!//.*$!!\'</span> $* | tr <span style="color: #ff0000;">\'@%<span style="color: #000099; font-weight: bold;">\0</span>12\'</span> <span style="color: #ff0000;">\'++@\'</span> | sed -e <span style="color: #ff0000;">\'s!<span style="color: #000099; font-weight: bold;">\*</span>/!%!g\'</span> | sed -e <span style="color: #ff0000;">\'s!/<span style="color: #000099; font-weight: bold;">\*</span>[^%]*%!!g\'</span> | tr @ <span style="color: #ff0000;">\'<span style="color: #000099; font-weight: bold;">\0</span>12\'</span> | grep -v <span style="color: #ff0000;">\'^[&nbsp; ]*$\'</span> | grep -v <span style="color: #ff0000;">\'^#[^!].*$\'</span> | wc -l`;<br />');
document.write('<span style="color: #000066;">echo</span> -en <span style="color: #ff0000;">&quot;$WITHOUTCOMMENTS<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br />');
document.write('&nbsp;</div>');
document.write('<br />&nbsp;<br /><div style="font-size: 12px">Brought to you by the community at <a href="http://www.bytemycode.com/snippets/snippet/362/1/" target="_blank">byteMyCode</a>.</div>');
