-a file exists. 

-b file exists and is a block special file. 

-c file exists and is a character special file. 

-d file exists and is a directory. 

-e file exists (just the same as -a). 

-f file exists and is a regular file. (常用)

-g file exists and has its setgid(2) bit set. 

-G file exists and has the same group ID as this process. 

-k file exists and has its sticky bit set. 

-L file exists and is a symbolic link. 

-n string length is not zero. 

-o Named option is set on. 

-O file exists and is owned by the user ID of this process. 

-p file exists and is a first in, first out (FIFO) special file or 

named pipe. 

-r file exists and is readable by the current process. 

-s file exists and has a size greater than zero. 

-S file exists and is a socket. 

-t file descriptor number fildes is open and associated with a 

terminal device. 

-u file exists and has its setuid(2) bit set. 

-w file exists and is writable by the current process. 

-x file exists and is executable by the current process.

-z string length is zero.

例子:

if [ -f "$LOG/cws_inv.data" ];then
rm $LOG/cws_inv.data
fi

注意:文件最好用”“括起来。

linux shell 判断文件是否存在等符号的更多相关文章

  1. Linux shell判断文件和文件夹是否存在

    shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/acc ...

  2. [转] Linux shell判断文件和文件夹是否存在

    shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/acc ...

  3. linux shell判断文件,目录是否存在或者具有权限

    在linux中判断文件,目录是否存在或则具有的权限,根据最近的学习以及网上的资料,进行了以下的总结: #!/bin/sh myPath="/var/log/httpd/" myFi ...

  4. Linux shell判断文件和文件夹是否存在(转发)

    #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的-x 参数 ...

  5. Linux Shell 判断块设备节点是否存在

    /************************************************************************* * Linux Shell 判断块设备节点是否存在 ...

  6. shell判断文件是否存在

    转自:http://www.cnblogs.com/sunyubo/archive/2011/10/17/2282047.html 1. shell判断文件,目录是否存在或者具有权限 2. #!/bi ...

  7. shell 判断文件、目录是否存在

    shell判断文件是否存在   1. shell判断文件,目录是否存在或者具有权限 2. #!/bin/sh 3. 4. myPath="/var/log/httpd/" 5. m ...

  8. Shell 判断文件或文件夹是否存在

    #shell判断文件夹是否存在 #如果文件夹不存在,创建文件夹 if [ ! -d "/myfolder" ]; then mkdir /myfolder fi #shell判断文 ...

  9. shell判断文件夹是否存在

    #shell判断文件夹是否存在 #如果文件夹不存在,创建文件夹 if [ ! -d "/myfolder" ]; then mkdir /myfolder fi #shell判断文 ...

随机推荐

  1. 【BZOJ2242】【SDOI2011】计算器

    Description 你被要求设计一个计算器完成以下三项任务: 1.给定y.z.p,计算y^z mod p 的值: 2.给定y.z.p,计算满足xy ≡z(mod p)的最小非负整数x: 3.给定y ...

  2. bzoj4517排列计数 错排+组合

    4517: [Sdoi2016]排列计数 Time Limit: 60 Sec  Memory Limit: 128 MBSubmit: 1491  Solved: 903[Submit][Statu ...

  3. 转载:使用Math.floor和Math.random取随机整数

    Math.random():获取0~1随机数 Math.floor() method rounds a number DOWNWARDS to the nearest integer, and ret ...

  4. mybatis什么时候用resulttype 什么时候用resultmap

    如果你搜索只是返回一个值,比如说String ,或者是int,那你直接用resultType就行了. 但是你如果是返回一个复杂的对象,就必须定义好这个对象的resultMap的result map. ...

  5. zkCli的使用 常用的节点增删改查命令用法

    zkCli的使用 常用的节点增删改查命令用法 1. 建立会话  命令格式:zkCli.sh -timeout 0 -r -server ip:port ./zkCli.sh -server -time ...

  6. hash数组快速查找一个字符串中出现最多的字符,并统计出现的次数

    如何快速查找一个字符串中出现最多的字符,并统计出现的次数? 可以使用hash数组,也就是关联数组实现快速查找功能. function seek(str) { var hash = []; var ma ...

  7. 网络不能上网但能ping通处理

    同事电脑不能上网,经过检查可以排除网线和网络问题,默认网关以及网页地址都能ping通,从网上搜索说是LSP问题,但是根据其操作方式修复,还是无效. 最后,不知道怎么捣鼓的,问题解决了. 操作流程: 1 ...

  8. Linux部分常用命令整理

    ./ 相当于双击 [oracle@linux01 ~]$ PWD 查看绝对路径 [oracle@linux01 ~]$ cd - 返回上一次操作的目录 [oracle@linux01 ~]$ cd . ...

  9. Luogu P3740 [HAOI2014]贴海报_线段树

    线段树版的海报 实际上这个与普通的线段树相差不大,只是貌似数据太水,暴力都可以过啊 本来以为要离散的,结果没打就A了 #include<iostream> #include<cstd ...

  10. c++类的声明

    就像函数的声明与定义分离一样,我们也可以仅声明类而暂时不定义类: class ClassName;//ClassName类的声明 这种声明有时被称作前向声明 对于一个类来说,我们创建它的对象之前该类必 ...