“cd” does not work in shell script
问题 I am wondering why cd does not work in shell script. It is as follows, #!/bin/sh cd test mkdir $(date +%d-%mm-%Y) When I run this, I get can't cd to test cd: 2: can't cd to /test Why is it like this? 回答1: I had the same problem. Turned out the problem was \r\n line endings. To fix it, do tr -d "\r" < oldname.sh > newname.sh From http://talk.maemo.org/showthread.php?s=1cadd53b369d5408c2b9d53580a32dc4&t=67836&page=2 回答2: Not really relevant for this question. I had the same error message,