![このコードに問題がありますか? [閉鎖]](https://linux33.com/image/41083/%E3%81%93%E3%81%AE%E3%82%B3%E3%83%BC%E3%83%89%E3%81%AB%E5%95%8F%E9%A1%8C%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%81%8B%EF%BC%9F%20%5B%E9%96%89%E9%8E%96%5D.png)
#!bin/bash
if [ ! -e $1 ];
then
echo "error... no such file"
exit
else
END=$(wc -l $1 | cut -d" " -f1)
for (( i=1;i<=END;i++));
do
echo -e " $i \n"
echo "$(head -$i $1 |tail -1)"
temp=$(head -$i $1 |tail -1|)
echo "this is temp $temp"
done
fi
失敗した行は私の割り当てですtemp
。エラーが発生しますsyntax error near unexpected token `)'
が、理由を理解できません。
答え1
コード内の次の|)
場所にタイプミスがあります。
temp=$(head -$i $1 |tail -1|)
パイプ(|
)を削除するか、他のコマンドに提供する必要があります。
答え2
エラーは次のとおりです。
temp=$(head -$i $1 |tail -1|)
あなたは排気管を書きました|
。
答え3
以前私が言及し、他の人が述べたように、コード行に構文エラーがあります。
temp=$(head -$i $1 |tail -1|)
これはおそらく次のとおりです。
temp=$(head -$i $1 |tail -1)