Shell Command basic parameter shell programming using the if statement to determine the parameter-B when the file exists and is a block file returns true-c when the file exists and is a character file returns true- d. When the pathname exists and is a directory, true-e is returned. When the file or directory specified by pathname exists, true-f is returned. When the file exists and is a regular file, true-g is returned. if the file or directory specified by pathname exists and the SGID bit is set, the returned result is true-h. If the file exists and is a symbolic link file, the returned result is true, this option is invalid in some old systems.-k. When a file or directory specified by pathname exists and a "Sticky" bit is set, true-p is returned when the file exists and is a command pipeline. true-r: if a file or directory specified by pathname exists and is readable, true-s is returned. If the file size is greater than 0, true-u is returned. If a file or directory specified by pathname exists when SUID bit is set, true-w is returned. When the file is specified by pathname Or returns true if the directory exists and is executable. A directory must be executable for its content access. -O returns true if a file or directory specified by pathname exists and the user specified by the valid user ID of the current process is owned by it. Compare characters in UNIX Shell:-eq equals-ne is not equal to-gt is greater than-lt is less than-le is less than or equal to-ge is greater than or equal to-z empty string = two characters are equal! = Two character unequal-n non-empty string ------------------------------------------------------------------------- for more details: Operator Description Example file comparison operator-e filename if filename exists, it is true [-e/var/log/syslog]-d filename. If filename is a directory, it is true [-d/tmp/mydir]-f filename. If filename is a regular file, it is true [-f/usr/bin/grep]-L filename. If filename is a symbolic link, it is true [-L/usr/bin/grep]-r filename. If filename is readable, it is true [-r/var/log/syslog]-w filename if f Ilename can be written, it is true [-w/var/mytmp.txt]-x filename if filename can be executed, true: [-L/usr/bin/grep] filename1-nt filename2. If filename1 is newer than filename2, if [/tmp/install/etc/services-nt/etc/services] filename1-ot filename2 is earlier than filename2, it is a true [/boot/bzImage-ot arch/i386/boot/bzImage] string comparison operator (please note the use of quotation marks, this is a good way to prevent space from disturbing the code) -z string: If the string length is zero, it is true [-z $ myvar]-n string. If the string length is not zero, it is true. [-N $ myvar] string1 = string2 if string1 is the same as string2, it is true [$ myvar = one two three] string1! = String2 if string1 is different from string2, it is true [$ myvar! = One two three] arithmetic comparison operator num1-eq num2 equals to [3-eq $ mynum] num1-ne num2 not equal to [3-ne $ mynum] num1-lt num2 less than [3 -lt $ mynum] num1-le num2 is less than or equal to [3-le $ mynum] num1-gt num2 is greater than [3-gt $ mynum] num1-ge num2 is greater than or equal to [3 -ge $ mynum] $ # Number of location parameters. $ * Content of all location parameters. $? Status returned after the command is executed. $ Process ID of the current process. $! The last process number that runs in the background. $0 indicates the name of the currently executed process. Where, $? Used to check whether the previous command is correctly executed. (In Linux, if the exit status of a command is 0, the command is correctly executed. If the value is not 0, an error occurs .)