title: unix -- get number of business days
body: <p>I'm using AIX with the ksh.  I'm trying to calculate the number of business days in a month.  I was trying to use AWK but I'm hung up now.</p>
  
  <p>Here's what I've got so far:</p>
  
  <pre><code>cal | awk '{print $2, $3, $4, $5, $6} | awk 'NR &gt; 2'
  </code></pre>
  
  <p>Here's the normal output (for current date/time) for cal:</p>
  
  <pre><code>        April 2014
  Sun Mon Tue Wed Thu Fri Sat
           1   2   3   4   5
   6   7   8   9  10  11  12
  13  14  15  16  17  18  19
  20  21  22  23  24  25  26
  27  28  29  30
  </code></pre>
  
  <p>Here's what I'm getting with that script:</p>
  
  <pre><code>2 3 4 5
  7 8 9 10 11
  14 15 16 17 18
  21 22 23 24 25
  28 29 30
  </code></pre>
  
  <p>My plan is to, in the end, read these lines into a c program and output the total weekdays (right now we're not worried about holidays on normal business days).  </p>
  
  <p>As you can see here, since the 3rd line of output is only 5 columns itself, it's dropping the 1st business day of that week.  Maybe I'm going about this whole thing wrong -- if there's another way to do this on the Unix operating system or through C: I have no sentimental attachment to "cal" and "awk" (not yet anyway).</p>