在shell中可以使用-e參數(shù)來判斷文件是否存在。具體命令如下:
-e
if [ -e file.txt ]; then echo "File exists" else echo "File not found" fi
其中file.txt為要判斷的文件名。如果文件存在,則會輸出"File exists";如果文件不存在,則會輸出"File not found"。
file.txt
億速云公眾號
手機網(wǎng)站二維碼
Copyright ? Yisu Cloud Ltd. All Rights Reserved. 2018 版權(quán)所有
廣州億速云計算有限公司粵ICP備17096448號-1 粵公網(wǎng)安備 44010402001142號增值電信業(yè)務經(jīng)營許可證編號:B1-20181529