美文网首页
test 命令

test 命令

作者: Ada_Corner | 来源:发表于2016-09-09 14:05 被阅读0次

test condition

if [ condition ] ; then

  commands

fi

test 命令的数值比较功能

比较                          描述

n1 -eq n2                 等于

n1 -ge n2                 大于或等于

n1 -gt n2                  大于

n1 -le n2                  小于或等于

n1 -lt n2                   小于

n1 -ne n2                  不等于

test 命令的字符串比较功能

比较                  描述

str1 = str2         相同

str1 != str2        不相同

str1 < str2          小

str1 > str2          大

-n str1               非0

-z str1               为0

test 命令的文件比较功能

比较                  描述

-d file              检查file是否存在并为一个目录

-e file              检查file是否存在

-f file                检查file是否存在并为一个文件

-r file                检查file是否存在并可读

-s file                检查file是否存在并非空

-w file               检查file是否存在并可写

-x file                检查file是否存在并可执行

-O file               检查file是否存在并属当前用户所拥有

-G file                检查file是否存在并且默认组与当前用户相同

file1 -nt file2     检查file1是否比file2新

file1 -ot file2     检查file1是否比file2旧 

相关文章

  • 【现学现忘&Shell编程】— 38.Shell中的条件判断(一

    1、test 测试命令 (1)test命令介绍 在Shell中的test测试命令,用于测试某种条件或某几种条件是否...

  • test 命令

    test condition if [ condition ] ; then commandsfi test 命令...

  • pthread_create

    编译运行命令gcc test.c -o test./test

  • shell脚本之if_else

    (一)if/else 命令 (二) test 命令 test命令提供了在if-then语句中测试不同条件的途径。如...

  • test命令

    关于某个文件名的“文件类型”判断,如test -e filename 表示存在否 -e 该“文件名”是否存在...

  • test命令

    Shell中的 test 命令用于检查某个条件是否成立,它可以进行数值、字符和文件三个方面的测试。 数值测试 例子...

  • Linux下如何修改用户默认目录

    切换到root用户,使用usermod命令, 例如usermod -d /tmp/test test (test为...

  • Jenkins自动化部署后端打jar包

    命令clean package -Dmaven.test.skip=true还有一种是跳过test的命令:pack...

  • shell基础

    test命令 test命令用于检查文件类型和比较值。Test使用在条件执行语句中。它用来: 文件属性比较 执行字符...

  • sed编辑器基础操作

    替换命令(substitute)$ cat data4This is a test of the test scr...

网友评论

      本文标题:test 命令

      本文链接:https://www.haomeiwen.com/subject/vgveettx.html