Silent_Rebel Silent_Rebel - 1 year ago 93
Linux Question

shell script throwing No such file or directory error while command line works perfect

I am trying to run a simple piece of shell script which return No such file or directory while executing the statement from command line works perfect.

Any leads ??

cat /home/dev/.bashrc

I am executing the code like
bash ~/Desktop/

Answer Source

You have a \r at the end of /bin/bash so it's trying to run /bin/bash\r which does not exist. Use just \n to terminate lines, like from a dos2unix tool or similar if you have it available.

That will also fix the \r at the end of your /home/dev/.bashrc

The \r in the shebang line isn't actually coming into play yet because you're invoking it as bash so it isn't using it, but it's the same problem