私はこのコードを持っています:
if [ -f "/mnt/usb/test/linuxConfig.json" ]
then
echo "usb på plats"
私が望むのは、ファイルが見つかったら(USBがマウントされていても)変数をtrueに設定することです。
USBがマウントされていることを確認するスクリプトを作成したいと思います。 USBをマウントしようとせずにパイを再起動できない場合に備えてください。
sleep
コマンドも使用したいので、変数はtrueまたはfalseでなければなりません。
ベストアンサー1
右の --branch で必要なすべての操作を簡単に実行できるので、その変数をどこで使用したいのかわかりませんif
。then
else
if [ -f "my/file" ]; then
echo 'Filen finns tillgänglig / the file is available'
else
echo 'Filen är inte där / the file is not there'
mount /mnt/something || { sleep 120; reboot; }
# or ... || shutdown -r +2 'Rebooting due to failed mount'
fi
「ブール」変数を使用するには:
found=0
[ -f "my/file" ] || found=1
if (( !found )); then
# file was not found
else
# file was found
fi