Posted on 2019-10-25 10:41
宋鵬 閱讀(555)
評(píng)論(0) 編輯 收藏 引用 所屬分類:
Linux
unix/windows回車問題
shell腳本執(zhí)行錯(cuò)誤 $'\r':command not found
存現(xiàn)這種錯(cuò)誤是因?yàn)?編寫的 shell腳本是在win下編寫的,每行結(jié)尾是\r\n 的Unix 結(jié)果行是\n
所以在Linux下運(yùn)行腳本 會(huì)任務(wù)\r 是一個(gè)字符,所以運(yùn)行錯(cuò)誤,需要把文件轉(zhuǎn)換下。
1.單個(gè)文件轉(zhuǎn)換:
運(yùn)行腳本
dos2unix 腳本名
OK
2.整個(gè)目錄中的文件做dos2unix操作:
$ find . -type f -exec dos2unix {} \;
其中具體命令的解釋如下:
find .
= find files in the current directory
-type f
= of type f
-exec dos2unix {} \;