シェルスクリプトの構文エラー

シェルスクリプトの構文エラー
 #!/bin/sh
df-H | grep -vE '^Filesystem|tmpfs|cdrom'| 
awk '{print $5" "$1}' while read output;
do
echo $output
usep=$(echo $output |awk '{print $1}'| cut -d'%'-f1)
partition=$(echo $output | awk '{print $2}')
if [#usep -ge 80]; then
echo 'running out of space 
\"$partition($usep%)\'on $(hostname)as on $(date)"|mail -s"alert:almost out of disk space $ usep% [email protected]);
f1 
Done;

スクリプトを実行すると、次のエラーが発生します。

line 6 Unexpected EOF WHILE LOOKING FOR MATCHING '"'
LINE 13 :syntax error : unexpected end of file:

ベストアンサー1

ラム、スクリプトを再確認する必要があります。スペルエラー(fiではなくf1、引用エラー)がたくさん含まれています。

私がやった方法は次のとおりです。 shはこれ以上文句を言わず、何をすべきかを自分で確認する必要があります。

#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom'| awk '{print $5" "$1}'
while read output;
do
echo $output
usep=$(echo $output |awk '{print $1}'| cut -d'%'-f1)
partition=$(echo $output | awk '{print $2}')
if [#usep -ge 80]; then
echo "running out of space \"$partition($usep%)\"on $(hostname)as on $(date)"|mail -s"alert:almost out of disk space $ usep% [email protected]);"
fi 
done

おすすめ記事