0

if 语句中的 -s switch 有什么作用?例如

if [ -s $File_name ]; then
   :
else
...

那么这个 -s 开关检查什么条件呢?

4

4 回答 4

4

此标志测试具有位置的文件是否$File_name存在且不为空(大小大于 0)。

于 2013-09-15T10:19:18.390 回答
2

man test说:

   -s FILE
          FILE exists and has a size greater than zero
于 2013-09-15T10:19:17.593 回答
1

在你的 shell 中运行man [,你会看到:

   -s FILE
          FILE exists and has a size greater than zero
于 2013-09-15T10:19:16.257 回答
1

根据这篇文章(和man test文档),它检查是否$File_file存在并且大小超过 0 字节。

于 2013-09-15T10:19:37.333 回答