I am trying to write a shell script that the user inputs what file they would like to rename as the first variable, then what they want the new name to be for it's second variable. The only output the program will give is that mv is missing file operand. I've hit a wall and am out of things to try at this point. I have tried using absolute paths to the file, which did not help. Google has turned up nothing for me.
The mv works as expected in the command line but as soon as variables are introduced the program goes kaput. I have tried every way of formatting my input possible.
#!/bin/bashecho -n "Original filename: "read $input_filenameecho ""echo -n "New filename: "read $output_filenameecho ""mv -v $input_filename $output_filenameif [ $? == 0 ]thenecho "Task completed successfully"else echo "ERROR: File failed to be renamed. Exiting."fi
Output and related file contents.
davevm@davevm-VirtualBox:~/lab10$ lshelloworld lab10.shdavevm@davevm-VirtualBox:~/lab10$ ./lab10.sh Original filename: helloworldNew filename: copy1mv: missing file operandTry 'mv --help' for more information.ERROR: File failed to be renamed. Exiting.