LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   mkdir won't work in a script but works on command line (https://www.linuxquestions.org/questions/linux-newbie-8/mkdir-wont-work-in-a-script-but-works-on-command-line-787044/)

ifeatu 02-04-2010 01:06 PM

mkdir won't work in a script but works on command line
 
Hey,

Code:

mkdir -p /cygdrive/c/Blah_Email_Backup/$i
This won't work in a script but it WILL work on the commandline...any suggestions

here is my output when I try the script:

Code:

mkdir: cannot create directory `/cygdrive/c/Blah_Email_Backup/amyerhoff@blah.com\r': No such file or directory
Also, what is the \r at the end of the path in the error??!!

Tinkster 02-04-2010 01:46 PM

Show us the code snippet that produces the message?

catkin 02-04-2010 02:25 PM

Looks like a Windows line end. Was the script created under Windows? The dos2unix command can be used to convert Windows line ends to Linux ones.

allanf 02-04-2010 02:26 PM

Most the value of "$i" contains the "CR/LF" line termination from "Windows" (or just the "CR" from Apple) as Linux/UNIX only used the "LF" portion. Easy fix if using BASH is:
Code:

mkdir -p /cygdrive/c/Blah_Email_Backup/${i%\\.}


All times are GMT -5. The time now is 07:47 PM.