Unix bash script (mv issues);

Hey guys,

I've registered here as I need urgent help. This is assignment for school and as you can see below I've completed the work. I'm simply stuck on one area.

:wall:

This script takes the first parameter (which is to be the new extension) and each parameter after that is a file name (which will have its old extension turned into the new one). Mind you, this script works almost perfectly.

The test script (the one that grades my assignment) forces this line to call the script running from the "filderFilesAreIn" directory:

./theScriptName.sh 'dat' 'file1.txt' 'file2.cpp' 'file3.dat' '../folderFilesAreIn/file4.dat'

My script does the first 3 files flawlessly. The 4th file, though, my code produces this output:

mv: `../folderFilesAreIn/file4.dat' and `../folderFilesAreIn/file4.dat' are the same file

It's strange as even though 'file3.dat' already exists, it replaces it with no error like above. The directory path before 'file4.dat' seem to cause the "mv -f" command to act differently.

In my code, I've used "mv -f" which is supposed to force the command to overwrite the file. This error isn't causing the program to not work but the test script (the one that grades the assignment for pass/fail) isn't letting me pass as this output is "unexpected" by it. This message is causing the script to think my code doesn't work because of the extra output.

Any help would be appreciated! I can't seem to find a way to cause "mv" to not produce any output. If I could silence the output or use another command to replace the file without getting any extra output it should count.

Thanks for your help! It's very frustrating and the teacher is being no help.

My full code is below (it's obviously not the best, but it's for a 1 credit class)
http://codeviewer.org/view/code:254d

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.