Linux !/bin/csh Cshell检查查找结果(如果有)

Linux !/bin/csh Cshell检查查找结果(如果有),linux,shell,csh,Linux,Shell,Csh,目标:检查查找结果,如果为空,则返回某个内容,如果不是,则返回查找结果 #!/bin/csh set mtime = 0; echo "<i>Title</i>" >> $outputfile set text=`find start*middle*.txt -mtime $mtime -ls` echo "$text" >> $outputfile - - 如果需要使用-mtime选项,则值0不正确。 如果要列出在最后一天创建的文件,则需要-m

目标:检查查找结果,如果为空,则返回某个内容,如果不是,则返回查找结果

#!/bin/csh
set mtime = 0;
echo "<i>Title</i>" >> $outputfile
set text=`find start*middle*.txt -mtime $mtime -ls`
echo "$text" >> $outputfile
-

-

如果需要使用-mtime选项,则值0不正确。 如果要列出在最后一天创建的文件,则需要-mtime-1和
连续两天-mtime-2

我不认为*csh有[[]]个Perhabs…只是尝试一下我在unix.stackexchange.com上找到的东西。您需要使用csh的原因是什么?真的。当然说旧服务器也有普通的sh?顺便说一句,这是另一篇文章,是对切普纳上面给出的链接的跟进。@DavidDunham你尝试过这个解决方案吗?
if (-f "$text" ) then
    echo Exists
else
    echo No such file
endif
if [[ -n $(find start*middle*.txt -mtime $mtime -ls) ]]
then
 echo "res" >> $outputfile
fi
if [[ -n "$text" ]]
then
 echo "res" >> $outputfile
fi
#!/bin/csh
set outputfile = test
set mtime = 0;
echo "<i>Title</i>" >> $outputfile
set text=`find start*middle*.txt -ls`
if ("$text" != "") then
        echo "exists"
else
        echo "dosn't exist"
endif
echo "$text" >> $outputfile