![同じ文字列の値の比較[閉じる]](https://linux33.com/image/80206/%E5%90%8C%E3%81%98%E6%96%87%E5%AD%97%E5%88%97%E3%81%AE%E5%80%A4%E3%81%AE%E6%AF%94%E8%BC%83%5B%E9%96%89%E3%81%98%E3%82%8B%5D.png)
私のスクリプトでは、次のようにWebサイトからデータを取得します。
content=$(wget 10.0.1.5:8000/currentsong?sid=1 -q -O -);
デフォルトでは Shoutcast サーバーの曲情報です。しかし、問題があります。私はこのようにしたいと思います。新しい値が文字列の以前の値と一致しない場合は、何かをする必要があります。そう:
if [ $content.new != $content.old ]; then
echo "New song info there.."
else
echo "NOTHING"
fi
どうすればいいですか?
編集する:スクリプトが以下で実行されることに言及するのを忘れました。リング。
答え1
私は次のことをします。
content=$(wget 10.0.1.5:8000/currentsong?sid=1 -q -O
content_old=$(cat /tmp/content.old)
if [ "$content" != "$content_old" ]; then
echo "New song info there.."
else
echo "NOTHING"
fi
echo $content > /tmp/content.old