2

I am trying to run a test.sh script file. I am using WSL2.

I am currently inside mnt/d/solid/test folder after running the command bash tests.sh it gives error

/mnt/d/solid/scripts/common.sh: line 21: $'\r': command not found.

Why this is executing inside scripts folder instead test folder.

I also tried this https://askubuntu.com/questions/966488/how-do-i-fix-r-command...

https://stackoverflow.com/questions/11616835/r-command-not....

But still getting same error

Toto
  • 89,455
  • 62
  • 89
  • 125
Sam
  • 43
  • 2
  • 9
  • you saved the script as CRLF, not LF. Convert it to LF an it'll work fine – phuclv Aug 06 '21 at 09:04
  • @phuclv I have already tried LF ending. Doesn't work. Neither the method given in the link it's also doesn't work – Sam Aug 06 '21 at 09:12
  • 1
    tried what? Is the output really LF? Show the commands you tried. Run `file /mnt/d/solid/scripts/common.sh` to see. Or if you have Notepad++, VS Code or VS open the file with them and check the line ending tyope – phuclv Aug 06 '21 at 09:14
  • I have a doubt, When I am executing file inside `test` folder, then why does it's running file in`scripts` folder ? – Sam Aug 06 '21 at 09:22
  • your script can `cd` into another folder as it wants. Nothing prevents it from doing that – phuclv Aug 06 '21 at 09:25
  • 1
    Thankyou got it. I have to change all the script file ending to LF. – Sam Aug 06 '21 at 09:40

0 Answers0