[reproduced] if parameters in shell script -a to -z

[-a file] True if file exists 

But it seems that sometimes -a is expressed as and: the condition and

[-b file] True if file exists and is a block special file 
[-c file] True if file exists and is a word special file 
[-d file] True if file exists and is a directory 
The ! before -d is a logical negation. 
For example: 
if [ ! -d $lcd_path/$par_date ] 
means that the following directory does not exist, then execute the following then operation 
[-e file] True if the file exists 
[-f file] True if file exists and is a normal file 
[-g file] True if file exists and SGID has been set (SUID is Set User ID, SGID is Set Group ID) 
[-h file] If True if file exists and is a symbolic link 
[-k file] True if file exists and the sticky bit is 
set When a directory has the "sticky bit" set (with chmod a+t), then the The file can only be 
deleted by 1. Super administrators 
2. The owner of the directory can delete it. 
3. The owner of the file can delete 
it. Delete Files. 
The specific example is as follows: 
#ls -dl /tmp 
drwxrwxrwt 4 root root ......... 
Pay attention to the t in the other position, which is the glue bit. 
[-p file] True if file exists and is a named pipe (F if O) 
Pipes are a way of inter-process communication in linux, others like signals, semaphores, message queues, shared Memory, sockets, etc. 
[-r file] True if file exists and is readable 
[-s file] True if file exists and size is not 0 
[-t FD] True if file descriptor FD is open and points to a terminal 
[-u file] True if file exists and SUID is set (set userID) 
[-w file] True if file exists and is writable 
[-x file] True if file exists and is executable true 
[-O file] true if file exists and is a valid user ID 
[-G file] true if file exists and is a valid user group 
[-L file] true if file exists and is a symbolic link 
[ -N file] True if file exists and has been mod if ied since it was last read 
[-S file] True if file exists and is a socket 
[file1 –nt file2] if file1 has been changed more True recently than file2 or file1 exists and file2 does not 
[file1 –ot file2] True if file1 is older than file2, or file2 exists and file1 does not exist 
[file1 –ef file2] 如果file1和file2指向相同的设备和节点号则为真 
[-o optionname] 如果shell选项“optionname”开启则为真 
[-z string] “string”的长度为零则为真 
[-n string] or [string] “string”的长度为非零non-zero则为真 
[sting1==string2] 如果2个字符串相同。“=”may be used instead of “==”for strict posix compliance则为真 
[string1!=string2] 如果字符串不相等则为真 
[string1<string2] 如果“string1”sorts before“string2”lexicographically in the current locale则为真 
[arg1 OP arg2] “OP”is one of –eq,-ne,-lt,-le,-gt or –ge.These arithmetic binary oprators return true if “arg1”is equal to,not equal to,less than,less than or equal to,greater than,or greater than or equal to“agr2”,respectively.“arg1”and “agr2”are integers. 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324848485&siteId=291194637