I have written a shell script called "a.sh" in linux with one line:
cd ..
: and then I run this with:
chmod +x a.sh
sh ./a.sh
: how do I run this without getting :
"Command not found" or "Can't cd". Maybe I have been looking at this code too long or am I doing something obviously wrong??
Note: I have since found out what was wrong. Emacs was inserting some strange "^m" character at the end of every line
cd is a builtin to your shell. Anything like /usr/bin/cd or /bin/cd just there for weird magical reasons.
First run this.
This will output the path to your sh executable
Try adding a shebang to your script. So the entire file looks like this
If that doesn't work then clarify the steps you've taken as Stefan has asked. As well as paste the exact error message.
what if you put /bin/cd in it's place.