0

I have been having issues changing directories using a shell script in windows 10.

In notepad I created a file, test.sh, which has the following script:

#!/bin/bash
cd '/mnt/p/WMScriptTest/'

I then mounted the Ubuntu terminal to the location of the test.sh file by typing in cd /mnt/p/ which works. Next, I typed in ./test.sh and keep getting the following error message:

: No such file or directory/p/WMScriptTest/

I am new to using ubuntu and any help/suggestions are greatly appreciated. Thank you

12
  • Please edit and add the output of ls -l /mnt/p. In a script one normally doesn’t use cd, but rather absolute paths. You can store paths in variables if that makes it easier, e.g. mypath=/mnt/p/WMScriptTest and then mkdir "$mypath/mydir" and cp "$mypath/file1" "$mypath/mydir".
    – dessert
    Jun 4, 2018 at 18:08
  • I just seem to be unable to change directories from code in my shell script. One of the folders listed from ls -l /mnt/p/ is WMScriptTest that I am trying to change directories to. If I change directories within the terminal itself it works though.
    – Justin S.
    Jun 4, 2018 at 18:44
  • Is the error message really (literally) : No such file or directory/p/WMScriptTest/? That looks mangled somehow…
    – dessert
    Jun 4, 2018 at 18:46
  • Yes, that is the exact message that I get
    – Justin S.
    Jun 4, 2018 at 18:47
  • 2
    Maybe a problem with line endings? askubuntu.com/q/803162/507051
    – dessert
    Jun 4, 2018 at 18:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy