How does Linux use if to determine whether a directory exists-linux operation and maintenance

1. Use if in the script to determine whether the directory exists #!/bin/bash if [ -d “c” ];then echo “directory c exists” else echo “Directory does not exist” fi Recommendation: Linux Tutorial Column 2. Simple writing method #!/bin/bash [ -d “c” ] && echo “directory c exists” # or [ -d “d” ] || echo “Directory d does not exist” More judgment formats are as follows: -e filename True if filename exists -d filename true if filename is a directory -f filename true if filename is a regular file -L filename true if filename is a symbolic link -r filename True if filename is readable -w filename true if filename is writable -x filename true if filename is executable -s filename True if file length is not 0 -h filename true if the file is a soft link

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索