Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您如何检查某个位置是否存在任何文件(用户选择)?
$org是我选择设置路径的变量
$org
if [ -e $org/$1] then echo "Do you want to overwrite" exit 1
我使用 if 语句还是 getopts?
-f检查路径是否存在并且是文件
-f
-d检查路径是否存在并且是目录
-d
$org/$1和之间应该有一个空格]。
$org/$1
]
尝试这个:
if [ -e "$org/$1" ]; then echo "Do you want to overwrite" fi
更多信息在这里:http ://tldp.org/LDP/abs/html/fto.html