title: replacing file name and content : shell script
body: <p>I have written the code for replacing content but quite confused with replacing file name, both in the same script. I want my script to run this way:</p>
  
  <pre><code>suppose I give input : ./myscript.sh abc xyz
  
  abc is my string to be replaced 
  xyz is the string to replace with
  </code></pre>
  
  <p>If some directory or any subdirectory or file in it has name abc, that should also change to xyz.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>filepath="/misc/home3/babitasandooja/fol1"
  for file in $(grep -lR $1 $filepath)
  do
  sed  -i "s/$1/$2/g" $file
  echo "Modified: " $file
  done
  </code></pre>
  
  <p>Now How should I code to replace the filename as well.</p>
  
  <p>I tried:</p>
  
  <pre><code>if( *$1*==$file )
  then  
  rename $1 $2 $filepath
  fi
  </code></pre>
  
  <p>and </p>
  
  <pre><code>find -iname $filepath -exec mv $1 $2 \;
  </code></pre>
  
  <p>but any of then is not working correctly. What should I do? Which approach should I take?</p>
  
  <p>Any help would be appreciated.
  Thanks :) </p>