title: Check file's content for even, odd or non-number characters and manage them appropriately
body: <p>The program takes 3 arguments: input file, output file for even numbers and output file for odd numbers.</p>
  
  <p>The task is to check the input and to put numbers into the proper files. 
  There can be other non-numeric characters in the input. </p>
  
  <p>In the end we need to provide user with the information how many odd, even and other characters were found.</p>
  
  <p>Here's a sample input file:</p>
  
  <pre><code>1 2 3 4 52
  9 2 32
  1 2 a
  9 2
  </code></pre>
  
  <p>sample output file for even:</p>
  
  <pre><code>2 4 52
  2 32
  2
  2
  </code></pre>
  
  <p>and sample output file for odd:</p>
  
  <pre><code>1 3
  9
  1
  9
  </code></pre>
  
  <p>And here's my current solution:</p>
  
  <pre><code>#!/bin/bash
  in=$1
  even=$2
  odd=$3
  
  regex='^[0-9]+$'
  
  num_even=0
  num_odd=0
  non_num=0
  
  while read -r line || [[ -n "$line" ]]; do
      for number in $line; do
          number=`echo "$number" | xargs`
          if [[ $number =~ $regex ]]; then
              if [[ $(( $number % 2 )) == 0 ]]; then
                  printf "$number " &gt;&gt; $even
                  num_even=$(($num_even+1))
              else
                  printf " $number" &gt;&gt; $odd
                  num_odd=$(($num_odd+1))
              fi
          else
              non_num=$(($non_num+1))
          fi
      done
      printf "\n" &gt;&gt; $even
      printf "\n" &gt;&gt; $odd
  done &lt;$in
  
  echo "Even numbers: " $num_even
  echo "Odd numbers: " $num_odd
  echo "Non num characters: " $non_num
  </code></pre>
  
  <p>It is working fine, however I'm very new to Bash and I wonder what could I've done better. Thank you! :)</p>