LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   MV command error (https://www.linuxquestions.org/questions/linux-newbie-8/mv-command-error-4175470375/)

shyamr 07-21-2013 06:31 AM

MV command error
 
Hi all,

I'm trying to use the mv command in my shell.
But when i execute the shell, /r gets appended to my directory and the file name(file name is input).tried using /$'\r'/ .but still face the same issue.

Please help

Thanks
Shyam

druuna 07-21-2013 06:47 AM

Hi and welcome to LQ!

Quote:

Originally Posted by shyamr (Post 4994102)
I'm trying to use the mv command in my shell.
But when i execute the shell, /r gets appended to my directory and the file name(file name is input).tried using /$'\r'/ .but still face the same issue.

Please show us the exact command you used and tell us what you are expecting the mv command to do.

shyamr 07-21-2013 06:55 AM

Below is the part of the shell
-----------------------------
#Declaration of directory path
LV_DATA_PATH="$NCBC_TOP/ncbc_swift" # NCBC_TOP is defined to the directory i need
LV_PARAM_PART21=`echo $LV_PARAM_PART2|awk -F"\" \"" '{print $1}'`
LV_PARAM_PART22=`echo $LV_PARAM_PART2|awk -F"\" \"" '{print $2}'`
LV_PARAM_PART23=`echo $LV_PARAM_PART2|awk -F"\" \"" '{print $3}'`
LV_FILE_NAME="${LV_PARAM_PART22/$'\r'/}"
echo $LV_FILE_NAME
echo $LV_DATA_PATH
mv $LV_DATA_PATH"/"$LV_FILE_NAME $LV_DATA_PATH"/"swift_ready"/"$LV_FILE_NAME

below is the output and error
-----------------------------
o5300142.out

/oracle/ebssit/a01/apps/apps_st/appl/ncbc/12.0.0/ncbc_swift

mv: cannot stat `/oracle/ebssit/a01/apps/apps_st/appl/ncbc/12.0.0/ncbc_swift\r/o5300142.out\r': No such file or directory

grail 07-21-2013 07:14 AM

Well first off, this would appear to be a script and not working directly in the shell.

As for the error, which now makes more sense, you have created the file in windows and then run it in linux. Issue is that windows uses \r\n for line endings
and hence any variable being set now has \r at the end of it.

Try running dos2unix over the script first and see how you go.


All times are GMT -5. The time now is 10:51 PM.