title: Renaming files in a UNIX directory - shell scripting
body: <p>I have been trying to write a script that will take the current working directory, scan every file and check if it is a .txt file. Then take every file (that's a text file), and check to see if it contains an underscore anywhere in its name and if it does to change the underscore to a hyphen.</p>
  
  <p>I know that this is a tall order, but here is the rough code I have so far:</p>
  
  <pre><code>#!/bin/bash
  count=1
  while((count &lt;= $#))
         do
            case $count in
                 "*.txt") sed 's/_/-' $count
            esac
            ((count++))
  done
  </code></pre>
  
  <p>What I was thinking is that this would take the files in the current working directory as the arguments and check every file(represented by $count or the file at "count"). Then for every file, it would check if it ended in .txt and if it did it would change every underscore to a hyphen using sed. I think one of the main problems I am having is that the script is not reading the files from the current working directory. I tried included the directory after the command to run the script, but I think it took each line instead of each file (since there are 4 or so files on every line).</p>
  
  <p>Anyway, any help would be greatly appreciated! Also, I'm sorry that my code is so bad, I am very new to UNIX.</p>