-1
の終了などのエラーをスローした場合、私は文がファイル
#!/bin/bash$
#x=new value$
#y=old value$
$
export PATH=/xxx/xxx/xxx:$PATH$
$
#get the difference of two files$
diff --side-by-side --suppress-common-lines file.txt file1.txt | tr -d "|,<,>,'\t'" | sed 's/ /:/g' | sed 's/^://' > diff.txt$
cat diff.txt$
$
#get the values$
for i in `cat diff.txt`; do$
plug_x=`echo $i | cut -d ":" -f1`$
echo "the value of jenkins plugin is $plug_x"$
ver_x=`echo $i | cut -d ":" -f2`$
echo "the value of jenkins version is $ver_x"$
plug_y=`echo $i | cut -d ":" -f3`$
echo "the value of db plugin is $plug_y"$
ver_y=`echo $i | cut -d ":" -f4`$
echo "the value of db version is $ver_y"$
if [ -z "$ver_y" ] && [ -z "$ver_x" ] ;$
then $
echo "the plugin is newly added"$
#newly added plugin should be updated in the db$
# mysql -u root -ppassword -h server --local-infile db << EOFMYSQL$
#update the table with the new version$
#EOFMYSQL$
else$
echo "the plugin has changes"$
mysql -u root -ppassword -h server --local-infile db << EOFMYSQL$
insert into table (xxx, xxx) values('$ver_x','$plug_x');$
$
EOFMYSQL $
fi$
done$
のようになりますが、私はこのスクリプトを実行すると、それは
Syntax error: end of file unexpected (expecting "fi")
を小夜が、Fiありthere..iカントあるスクリプトを持っていますなぜそれがエラーを投げているのかわかりません 私はスクリプト内にecho文を持っているだけで、このエラーは出ません。
この文書の末尾に続く空白がある可能性はありますか? 'cat -e file.sh'を使ってあなたのスクリプトを見てください –
cat -e script.shの出力スクリプトで私の質問を編集しました – panda
ところで、' $ 'はこれをコピーアンドペースト(f/e、 http://shellcheck.net/に)。 –