Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of judging the existence of a file or directory by linux through if statement

Shulou Source: shulou.com Published: 2022-06-03 02:54:41 09月22日 Update

Catalog judgment:

Path= "/ home" # if [!-d ${path}]; then if [- d ${path}]; then echo dir ${path} exist! Else echo dir ${path} not exist! Fi

Document judgment:

File= "/ home/log.txt" if [- f ${file}]; then echo file ${file} exist! Else echo file ${file} not exist! Fi

These are the details of how to determine the existence of a file or directory through if statements in linux. Please pay more attention to other related articles!

Tags: Files directories statements contents that is articles more methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB Microsoft Apple Shulou Information