我正在使用csh脚本来检查任何文件是否存在。
if [ -f /var/opt/temip/conf/.temip_config ]
但是我遇到了以下错误
if [ -f /var/opt/temip/conf/.temip_config ]
if: Expression Syntax.
有人能告诉我如何做这件事吗?
-e
选项。文件名不必像if语句那样“硬编码”,而是可以像这样作为参数: if (-e "$filePath") then
这里是Cshell文件查询的完整列表。
-e file file merely exists (may be protected from user)
-r file file exists and is readable by user
-w file file is writable by user
-x file file is executable by user
-o file file is owned by user
-z file file has size 0
-f file file is an ordinary file
-d file file is a directory
sh
来说是可以的,而且这也是你应该使用的。但是,如果没有其他脚本的上下文,我们无法确定将第一行更改为#!/bin/sh
是否可行。 - tripleeecsh
。在 POSIX sh(为了可移植性),GNUbash
,Python或zsh
中编写您的脚本。 - Basile Starynkevitch