在shell中,可以使用-e参数来判断文件是否存在。下面是一个示例代码:
#!/bin/bashfile="/path/to/file.txt"if [ -e "$file" ]; then echo "File exists"else echo "File does not exist"fi上面的代码会检查指定的文件是否存在,如果文件存在,则输出"File exists",否则输出"File does not exist"。
在shell中,可以使用-e参数来判断文件是否存在。下面是一个示例代码:
#!/bin/bashfile="/path/to/file.txt"if [ -e "$file" ]; then echo "File exists"else echo "File does not exist"fi上面的代码会检查指定的文件是否存在,如果文件存在,则输出"File exists",否则输出"File does not exist"。