Why does my bash script not cd correctly?

I'm using Windows Subsystem for Linux, and learning the terminal. I want to open applications on my desktop with the terminal, so I decided to make a bash script to cd to the .exe file and run it.

This is what I have:

cd "/mnt/Users/username/AppData/Local/Programs/'Opera GX'/"
./launcher.exe

However, it gives me this error:

./operaLaunch.sh: line 1: cd: $'/mnt/Users/akaza/AppData/Local/Programs/Opera GX/\r': No such file or directory
./operaLaunch.sh: line 2: ./launcher.exe: No such file or directory

I don't know why the line 1 is different in the error message.

Edit: So, I downloaded Notepad++ and changed the line endings to the proper Unix ones, but still not getting the script to work. Also, yes, I had a typo in the quoting of my script. This is how my script looks now

cd "/mnt/c/Users/akaza/AppData/Local/Programs/'Opera GX'/"
./launcher.exe

This is the error message I get now:

./operaLaunch.sh: line 1: cd: /mnt/c/Users/akaza/AppData/Local/Programs/'Opera GX'/: No such file or directory
./operaLaunch.sh: line 2: ./launcher.exe: No such file or directory 

Maybe the whitespace?

9

1 Answer

So, thanks to Kamil Maciorowski for helping me understand, the problem was with the inclusion of the single-quotes inside of the double-quotes. After removing the single-quotes, my script is working as intended. Thanks for the help

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like