我有一個bash腳本,當在RHEL或OS X上運行,提供了以下錯誤:Bash腳本大小限制?
line 62484: syntax error near unexpected token `newline'
line 62484: ` -o_gz'
這是一個自動生成的腳本來解決在使用的網格引擎計算集羣引進的限制我的公司。它全部由一組幾乎相同的if/elif
組成。我看不出錯誤來自哪裏。當我在錯誤行之前運行腳本的開始部分時,它沒有問題。這讓我覺得可能有一些bash腳本長度限制。我能在網上找到的唯一參考是comment by iAdjunct。
圍繞錯誤的腳本的部分看起來像這樣(有一些簡化):
.
.
.
.
elif [ $task_number -eq 2499 ]
then
/some/tool/executable \
-use_prephased_g \
-m \
/some/text/file \
-h \
/some/zipped/file \
-l \
-int \
45063854 \
46063853 \
-Ne \
20000 \
-o \
/some/output/file \
-verbose \
-o_gz #==============> ****THIS IS LINE 62484****
elif [ $task_number -eq 2500 ]
then
/some/tool/executable \
-use_prephased_g \
-m \
/some/other/text/file \
-h \
/some/other/zipped/file \
-l \
-int \
98232182 \
99232182 \
-Ne \
20000 \
-o \
/some/other/output/file \
-verbose \
-o_gz
elif [ $task_number -eq 2501 ]
.
.
.
.
這是否響任何人任何鐘聲?
嘗試http://www.shellcheck.net/ – Sundeep
如果'elif's之間的唯一區別是* $ task_number *和三個* -int *和* -Ne *數字,並且'-m '和'-h'文件名,那麼它實際上是一個輸入一個變量的函數,並返回三個數字和兩個文件名。將所有四個數字和兩個文件名放在一個表或數組中,使一個函數返回所需的條件輸出會更簡單,然後腳本不需要* any *'if's或'elif's - 一個函數調用將完成數千個「elif」的工作。 – agc