title: Move Files to Files with old extension in same directory
body: <p>I have a question after the errors I am getting for an assignment as it seems to work on my own tests. I will post the script and the errors below.
  Bash Script</p>
  
  <pre><code>#!/bin/bash
  for file in $1
  do $file | grep \.old$ &gt; /dev/null
   if [ "$file" != 0 ]
  then mv $file $file.old
  else $file
  fi
  done
  
  Files created in 'testdir:
  
  file1  file2.old  file3old  file4.old
  
  Execution of 'oldfiles testdir':
  
  
  'oldfiles testdir' incorrectly produced some output or errors:
  for file in $1
    do $file | grep \.old$ &gt; /dev/null
    if [ "$file" != 0 ]
      then mv $file $file.old
    else $file
    fi
  done
  + for file in '$1'
  + grep '.old$'
  + /var/tmp/uli101.npkrause.assign4.8938.testdir
  /home/npkrause/scripts/oldfiles: line 4: /var/tmp/uli101.npkrause.assign4.8938.testdir: Is a directory
  + '[' /var/tmp/uli101.npkrause.assign4.8938.testdir '!=' 0 ']'
  + mv /var/tmp/uli101.npkrause.assign4.8938.testdir /var/tmp/uli101.npkrause.assign4.8938.testdir.old
  
  Files in 'testdir' after 'oldfiles' was run:
  ls: cannot access /var/tmp/uli101.npkrause.assign4.8938.testdir: No such file or directory
  
  Filenames don't seem to be correct
  
  Please hit &lt;Enter&gt; to continue with the Assignment
  </code></pre>