0

I am currently trying to run a bash script to jump between specific directories and print out all the .cpp and .h files found in that directory.

But when i try to use the cd command in the .sh, I get the error "no such working directory".

e.g. cd myDir

but the script returns, cd: $'myDir\r': No such file or directory

I dont understand why the \r is there, or how to remove it.

When i run the command from the terminal i have no issues. Any ideas where im going wrong?

Thanks in advance

  • 2
    The trailing `\r` indicates you save the file with MS DOS line endings; remove the `\r`s and you should be good. The dos2unix tool may be helpful, or a simple search and replace. – Robert Jul 25 '23 at 14:10
  • Probably you use editor which inserts incorrect characters at end of lines. In linux lines must end with '\n' – dimich Jul 25 '23 at 14:10

0 Answers0