title: Bash Move file and rename with incrementing extension
body: <p>I have to write a Bash script that will look to see if a file exists and move the file to a specific directory, then rename the file with an extension of .1 or .2 etc if .1 already exists.  I feel like I have a good start on it but it's not recognizing the directory even though I can enter mv file destination directly and it works.  Where am I going wrong?</p>
  
  <pre><code>#!/bin/bash
  DESTINATION="~hbrown31/homework"
  FILE=$1
  if [ -e "$FILE" ]
   then
    for $FILE in 'ls|sort -g -r'
     do
      echo "File is being moved and renamed"
      NEWFILE="$DESTINATION""$FILE""."
      mv "$FILE" "$(NEWFILE + 1)"
     fi
   else
    echo "File does not exist"
  fi
  </code></pre>