• 文件测试表达式
  • Shell 文件测试表达式

    文件测试表达式

    常见

    -f  file    文件存在且为普通文件 file
    -d  file    文件存在且为目录 directory
    -s  file    文件存在且大小不为0 size
    -e  file    文件存在则为真,只要有文件就行 exists
    -r  file    文件存在且可读 read
    -w  file    文件存在且可写 write
    -x  file    文件存在且可执行 execute
    -L  file    文件存在且为链接 link
    f1 -nt f2   f1比f2新  newer than
    f1 -ot f2   f1比f2旧  older than
    
    如果vimrc 文件存在则返回1否则返回0
    [ -f /etc/vim/vimrc ]&& echo 1|| echo 0
    

    上一篇:人生的意义

    下一篇:Shell 字符串操作符