Issue
I have a file in unix with name as "this is my file.xls"
I want to move it from one folder to other. I wrote the below lines:
fileName="this is my file"
myDate=20121125
mv $FIRST_DIR/"${fileName}.xls" $SECOND_DIR/"${fileName}_${myDate}.xls"
However, this is not working. I am getting error as "file.xls is not a directory"
What is the correct way to do this?
Thanks for reading!
Solution
Use escape characters for spaces. So change the variable fileName
to "this\ is\ my\ file". This ensures that the shell will ignore the spaces and won't consider it as a delimiter.
Answered By - Amal Antony Answer Checked By - Mildred Charles (WPSolving Admin)