`
icekiller110
  • 浏览: 69326 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Linux / Unix Command: test

阅读更多
内容来源 : http://linux.about.com/library/cmd/blcmdl1_test.htm

NAME

test - check file types and compare values 
SYNOPSIS

test EXPRESSION
[ EXPRESSION ]
test OPTION 
DESCRIPTION

Exit with the status determined by EXPRESSION.

--help
display this help and exit
--version
output version information and exit
EXPRESSION is true or false and sets exit status. It is one of:

( EXPRESSION )
EXPRESSION is true
! EXPRESSION
EXPRESSION is false
EXPRESSION1 -a EXPRESSION2
both EXPRESSION1 and EXPRESSION2 are true
EXPRESSION1 -o EXPRESSION2
either EXPRESSION1 or EXPRESSION2 is true
[-n] STRING
the length of STRING is nonzero
-z STRING
the length of STRING is zero
STRING1 = STRING2
the strings are equal
STRING1 != STRING2
the strings are not equal
INTEGER1 -eq INTEGER2
INTEGER1 is equal to INTEGER2
INTEGER1 -ge INTEGER2
INTEGER1 is greater than or equal to INTEGER2
INTEGER1 -gt INTEGER2
INTEGER1 is greater than INTEGER2
INTEGER1 -le INTEGER2
INTEGER1 is less than or equal to INTEGER2
INTEGER1 -lt INTEGER2
INTEGER1 is less than INTEGER2
INTEGER1 -ne INTEGER2
INTEGER1 is not equal to INTEGER2
FILE1 -ef FILE2
FILE1 and FILE2 have the same device and inode numbers
FILE1 -nt FILE2
FILE1 is newer (modification date) than FILE2
FILE1 -ot FILE2
FILE1 is older than FILE2
-b FILE
FILE exists and is block special
-c FILE
FILE exists and is character special
-d FILE
FILE exists and is a directory
-e FILE
FILE exists
-f FILE
FILE exists and is a regular file
-g FILE
FILE exists and is set-group-ID
-h FILE
FILE exists and is a symbolic link (same as -L)
-G FILE
FILE exists and is owned by the effective group ID
-k FILE
FILE exists and has its sticky bit set
-L FILE
FILE exists and is a symbolic link (same as -h)
-O FILE
FILE exists and is owned by the effective user ID
-p FILE
FILE exists and is a named pipe
-r FILE
FILE exists and is readable
-s FILE
FILE exists and has a size greater than zero
-S FILE
FILE exists and is a socket
-t [FD]
file descriptor FD (stdout by default) is opened on a terminal
-u FILE
FILE exists and its set-user-ID bit is set
-w FILE
FILE exists and is writable
-x FILE
FILE exists and is executable
Beware that parentheses need to be escaped (e.g., by backslashes) for shells. INTEGER may also be -l STRING, which evaluates to the length of STRING. 

SEE ALSO

The full documentation for test is maintained as a Texinfo manual. If the info and test programs are properly installed at your site, the command
info test
should give you access to the complete manual.
分享到:
评论

相关推荐

    Your.UNIX.Linux.The.Ultimate.Guide.3rd.Ed

    Your UNIX/Linux: The Ultimate Guide, written with both users and programmers in mind, is the ultimate UNIX/Linux text. Both pedagogical tool and exhaustive reference, it is well-suited to any course ...

    Linux FTP服务配置

    vsftp默认目录为:/var/ftp,为方便测试,在/var/ftp下新建一个文件"testLocal",在"/var/ftp/pub"新建一个文件"testAnon"。 由于使用root用户新建文件,文件的所有者为root,所以需要把文件的权限设置为644其他用户...

    netcat 瑞士军刀 linux windows netcat 瑞士军刀 linux windows

     nc -l -p port -e /bin/sh //unix,linux  attacker machine: //攻击者的机器.  nc ip -p port //连接victim_IP,然后得到一个shell。  3.4.反向连接  attacker machine: //一般是sql2.exe,远程溢出,webdavx...

    CompTIA Linux+ Exam LX0-103 and Exam LX0-104, 3rd Edition

    The CompTIA Linux+ Powered by LPI exams test a candidate's understanding and familiarity with the Linux Kernel. * Review the basic system architecture, installation, and management * Understand ...

    SimIt-ARM-3.0 ARM指令模拟器

    ./build/bin/ema test/wc configure modifiy PATH environment variable: PATH=$PATH:$HOME/SimIt-ARM-3.0-gk/build/bin ; export PATH 2. how to use 2.1 run user-level ARM programs [root@ORA9 SimIt-ARM-3.0-...

    linux vi 常用命令

    进入vi 在系统提示符号输入vi及文件名称后,即可进入vi全屏幕编辑画面: $ vi testfile 有一点要特别注意,就是您进入vi之后是处于“Command mode”下,您要切换到Insert mode才能输入文字。 初次用vi的用户都会想先...

    cmd操作命令和linux命令大全收集

    CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本、文件系统版本) 命令大全 1. gpedit.msc-----组策略 2. sndrec32-------录音机 3. Nslookup-------IP地址侦测器 ,是一个 监测网络中 DNS...

    CompTIA.Linux.LPIC-1.Cert.Guide.07897545

    The LPIC-1 Authorized Cert Guide has a single goal: to help you pass the new version of the Linux Professional Institute LPIC-1 exams. The most comprehensive and time-efficient LPIC-1 study guide ...

    MobaXterm Pro 11.0.3816

    Improvement: improved compatibility of “Follow terminal folder” feature with remote Unix/Linux environments Improvement: added a prompt dialog in order to assign right-click action (context menu or ...

    NC源码和程序附上目前最详细的使用手册和使用技巧

    平台:Linux/BSD/Unix/Windows WINDOWS下版本号:[v1.10 NT] 参数介绍: *nc.exe -h*即可看到各参数的使用方法。 基本格式:nc [-options] hostname port[s] [ports] … nc -l -p port [options] [hostname]...

    NC原版与VC60版本

    平台:Linux/BSD/Unix/Windows WINDOWS下版本号:[v1.10 NT] 参数介绍: *nc.exe -h*即可看到各参数的使用方法。 基本格式:nc [-options] hostname port[s] [ports] … nc -l -p port [options] [hostname] [port] ...

    ELDK使用与开发手册

    http://archiv.leo.org/pub/comp/os/unix/linux/eldk/ 3.2 初始安装 初始安装可以使用放在ELDK目录树根目录下的安装工具。安装工具使用语法如下; $ ./install [-d ] [] [] … -d <dir> 确定ELDK安装在哪个目录。...

    Linux操作系统基础教程

    Linux 是在 1991 年发展起来的与 UNIX兼容的操作系统,可以免费使用,它的源代码 可以自由传播且可任人修改、充实、发展,开发者的初衷是要共同创造一个完美、理想并 可以免费使用的操作系统。 我们并不能使同学...

    drupal 6.12

    For more information on setting file permissions, see "Modifying Linux, Unix, and Mac file permissions" (http://drupal.org/node/202483) or "Modifying Windows file permissions" ...

    hydra 7.2 win32

    All UNIX platforms (linux, *bsd, solaris, etc.) Mac OS/X Windows with Cygwin (both ipv4 and ipv6) Mobile systems based on Linux or Mac OS/X (e.g. Android, iPhone, Zaurus, iPaq) HOW TO USE ---------...

    UNIX环境高级编程英文第三版+源码

    2.7 Feature Test Macros 57 2.8 Primitive System Data Types 58 2.9 Differences Between Standards 58 2.10 Summary 60 Chapter 3. File I/O 61 3.1 Introduction 61 3.2 File Descr iptors 61 3.3 open and ...

    Linux使用教程(教程)

    7.Linux与UNIX有什么不同? 6 8.Linux能应用在哪些领域呢? 6 9.Linux作系统发展现状和未来如何? 6 10.Linux对软件业有什么影响呢? 6 11.我该如何学习Linux呢? 6 12.网上有哪些Linux资源? 7 13.RedHat Linux 6.5...

    cJSON-master.zip

    Run this command in the directory with the source code and it will automatically compile static and shared libraries and a little test program (not the full test suite). ``` make all

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 登陆服务器时输入 公帐号 openlab-open123 telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss 老师测评网址 http://172.16.0.198:8080/poll/ 各个 ...

    linux.chm文档

    rar a file1.rar test_file 创建一个叫做 'file1.rar' 的包 rar a file1.rar file1 file2 dir1 同时压缩 'file1', 'file2' 以及目录 'dir1' rar x file1.rar 解压rar包 unrar x file1.rar 解压rar包 tar -cvf ...

Global site tag (gtag.js) - Google Analytics