ファイルが存在することを確認しない場合は、ファイルを作成して次のコマンドを続行するか、次のコマンドを続行するシェルスクリプトを作成する必要があります。私が持っていることはそのようなことをしません。
#!/bin/bash
# Check for the file that gets created when the script successfully finishes.
if [! -f /Scripts/file.txt]
then
: # Do nothing. Go to the next step?
else
mkdir /Scripts # file.txt will come at the end of the script
fi
# Next command (macOS preference setting)
defaults write ...
返されるもの
line 5: [!: command not found
mkdir: /Scripts: File exists
何をすべきかわかりません。 Google 検索で読み込んだすべての場所に別のコンテンツが表示されました。
ベストアンサー1
明示的なテストなしでより簡単な解決策は、次のようになります。
mkdir -p /Scripts
touch /Scripts/file.txt
file.txt
既存の「修正」時間を変更したくない場合は、makeを使用して「アクセス」および「変更」時間のみを変更touch
できます。touch -a /Scripts/file.txt
touch