Shell報錯syntax error: unexpected end of file
執行shell指令碼檔案,報錯syntax error: unexpected end of file
。
使用vim工具開啟指令碼檔案,卻並沒有發現有什麼問題。
vim hello.sh
但是隻需要使用vim+引數的方式開啟該檔案,就會發現一些端倪。
vim -b hello.sh
在每一個shell
語句的末尾,都多了一個^M
的標誌,這其實是因為該檔案是在windows
環境下編寫,然後傳輸到Linux
環境來的,但是因為windows
環境的文字有\r
的回車標識,在Linux
環境下就會出現不相容的問題。
解決方法:
1、只需要把^M
的標誌符刪除,該指令碼檔案即可正常執行。不過這種方法只適用於少量文字,如果是大量的指令碼程式碼,這顯然是不適用的。
2、通過命令的方式,將shell檔案的格式改為unix。
vim hello.sh
:set fileformat=unix
:x
使用
vim
編輯文字的時候,不要使用-b
引數,否則是無法將shell
檔案的檔案格式修改為unix
的。
相關推薦
Shell報錯syntax error: unexpected end of file
技術標籤:Linuxlinuxshell 執行shell指令碼檔案,報錯syntax error: unexpected end of file。
uniapp報錯記錄:Unexpected end of JSON input、
1、Unexpected end of JSON input原因及如何解決 總是遇到一個報錯,導致有時候渲染有問題,我們看看啥報錯:
shell指令碼:報錯syntax error near unexpected token `$'\r''解決方法
之前的shell指令碼是在伺服器上編寫的,後來又已複製的方式存在在了電腦上,以txt檔案的形式存放的。於是複製到了編輯工具中,進行了相應項的修改。修改完畢後,拿到伺服器上測試,結果執行sh XXX.sh後就一直提示
mysql/mariadb很慢,報錯:InnoDB: ERROR: the age of the last checkpoint is
問題 mysql最新網路吞吐速度慢,到後臺檢視日誌報錯: Version: \'5.5.65-MariaDB\'socket: \'/var/lib/mysql/mysql.sock\'port: 3306MariaDB Server
mysql syntax error at end of input
select exists ( select 1 from ( select ssrs.isenabled,ssi.skcode,ssi.shopcode from set_syn_relation_shop ssrs inner join set_shop_info ssi
請求伺服器異常:JSON parse error: Unexpected end-of-input: was expecting closing ‘“‘ for name; nested excep
技術標籤:java @[TOC](請求伺服器異常:JSON parse error: Unexpected end-of-input: was expecting closing ‘"’ for name; nested exception is … ‘"’ for name at [Source: (PushbackInputStr
vue/cli建立的typescript專案,引入less一直報錯Syntax Error: TypeError: this.getOptions is not a function
技術標籤:一些學習的研究新手入門vuetypescript 錯誤提示如下 Syntax Error: TypeError: this.getOptions is not a function
eslint報錯Parsing error: Unexpected token prettier/prettier
問題描述 index.html檔案首行 eslint 報錯Parsing error: Unexpected token prettier/prettier caused by "<!DOCTYPE html>"
Android Studio中出現unexpected end of file
在編寫xml檔案時出現了 unexpected end of file 的命令錯誤檢查發現編寫過程中漏掉一個<LinearLayout的結束語 新增之後錯誤消 我們在編寫xml檔案時常常出現檔案下方出現紅色波浪線的情況,一般都是佈局結
PhpAdmin安裝報錯, php syntax error, unexpected T_STRING on line 8
0x00漏洞成因: 第一行的警報意思是 不支援在C:\\BtSoft\\phpmyadmin\\phpmyadmin J8B4R5KlhA1p7DF8\\index.php第8行中宣告“嚴格型別
django執行遷移檔案報錯struct.error: unpack requires a buffer of 4 bytes
問題: 我使用的版本說明 django:2.2版本 djangorestframework:3.11版本 python3.6版本 解決 查了下資料,沒有很詳細的說明,我是因為需要使用django中的自帶的User模型,需要配置AUTH_USER_MODEL,但是我不是第一
Docker push 報錯:received unexpected HTTP status: 500 Internal Server Error
現象描述 將映象推送到私有倉庫,出現錯誤“received unexpected HTTP status: 500 Internal Server Error”
Linux7安裝Oracle 11g 86%報錯:Error in invoking target 'agent nmhs' of makefile
環境資訊: OS:Oracle Linux 7、Redhat 7、CentOS7 DB:Oracle 11.2.0.4 報錯資訊: 原因分析:
gitlab smtp設定和注意事項 ||報錯EOFError: end of file reached
配置路徑選項:/etc/gitlab/gitlab.rb 可以根據自己實際安裝目錄進行尋找,或使用find name gitlab.rb 查詢所在目錄
mysql8.0版本 報錯:Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol...
mysql8.0版本 報錯:Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
解決java執行cmd命令呼叫ffmpeg報錯Concat error - No such filter '[0,0]'問題
最近公司有一個公交專案,要生成報站語音,採用的是 報站字首 + 站點名 + 報站字尾,3個MP3檔案拼接的方式,拼接成一個完整的語音,且需要轉位元速率和位元率,使用到了ffmpeg。
Jenkins整合k8s報錯:Error testing connection https://kubernetes.default.svc.cluster.local: Failure
背景:jenkins部署在k8s中的名稱空間infra中 Jenkins整合k8s報錯連線測試報錯: Error testing connection https://kubernetes.default.svc.cluster.local: Failure executing: GET at: https://kubernetes.defaul
親測解決npm ERR! Unexpected end of JSON input while parsing near...的方法
今天在建立專案的時候,發現一直建立不成功,安裝專案依賴的時候報錯:npm ERR! Unexpected end of JSON input while parsing near…
IDA報錯fatal error before kernel init
編寫了一個IDA64外掛,結果再開啟IDA後報錯fatal error before kernel init,然後閃退。
使用gitLab clone程式碼報錯:error: RPC failed; curl 56 OpenSSL SSL_read: Connection was reset
在clone程式碼的時候,報錯如下: 並且在報錯的時候,VPN自動斷線,之後自動連線。原本以為是VPN不穩定的緣故。重啟之後,還是不行。