posts - 54, comments - 32, trackbacks - 0, articles - 0
unix/windows回车问题
shell脚本执行错误 $'\r':command not found
存现这种错误是因为 编写的  shell脚本是在win下编写的,每行结尾是\r\n 的Unix 结果行是\n  
所以在Linux下运行脚本 会任务\r 是一个字符,所以运行错误,需要把文件转换下。
1.单个文件转换:
运行脚本 
 dos2unix  脚本名
OK
2.整个目录中的文件做dos2unix操作:
$ find . -type f -exec dos2unix {} \;
其中具体命令的解释如下:
find .
= find files in the current directory
-type f
= of type f
-exec dos2unix {} \;

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理