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
ls -l /mnt/p. In a script one normally doesn’t usecd, but rather absolute paths. You can store paths in variables if that makes it easier, e.g.mypath=/mnt/p/WMScriptTestand thenmkdir "$mypath/mydir"andcp "$mypath/file1" "$mypath/mydir". – dessert Jun 04 '18 at 18:08: No such file or directory/p/WMScriptTest/? That looks mangled somehow… – dessert Jun 04 '18 at 18:46sedapproach maybe? ;P Oh, does it work in the command line directly btw? Please trybash -c "cd '/mnt/p/WMScriptTest/' && pwd", this should print “/mnt/p/WMScriptTest”. – dessert Jun 04 '18 at 19:01pwdafter thecdline. If you actually want to do something completely different, please [edit] your question and change it accordingly. – dessert Jun 04 '18 at 19:18