1,Echo $?: An exit status is returned when any command is running, and the exit status of the previous command is output,0Indicates that the exit is successful.
2, Test File status:[-W text]Test whether the file can be written,Echo $?The output is0Indicates writable; otherwise, it cannot be written.
[-D text]Is the file a directory,Echo $?The output is1Indicates that it is not a directory.0Indicates conformity,1Indicates non-conformity.
[-W text-a-d text]Is the file writable and path,-Indicates the sameAnd,-OIndicatesOr
-DDirectory-SThe file length is greater0, Not empty
-FRegular File-WWritable
-LSymbolic connection-UFile hasS u I dBit settings
-RReadable-XExecutable
3, Test string:[String string_operator string]: For example[$ Leeboy = "hello"],[-Z
$ Leeboy].
=The two strings are equal .!=Two strings.-ZEmpty string.-NNon-empty string.
4, Test value:[Number number_operator number]: For example[$ Leeboy-EQ 9]
-EQThe value is equal.
-NeThe values are not equal.
-GTThe first number is greater than the second number.
-LtThe first number is smaller than the second number.
-LeThe first number is less than or equal to the second number.
-GeThe first number is greater than or equal to the second number.
5,IfIn the script.
#! /Bin/sh # Check whether the input is empty echo-e "enter your name: \ c" read nameif ["$ name" = ""] # Double quotation marks must be used here, otherwise, thenecho "You did not enter your name! "Elif [" $ name "=" leeboy "]; then # If then is written in a row, add"; "Echo" you are the one! "Elseecho" Hello $ name! "Fi
6Input parameters for the script
#! /Bin/sh # determine the number of input parameters if [$ #-lt 3] # $ # is the number of parameters thenecho "Usage: 'basename $0 ': arg1 arg2 arg3 "Exit 1 fiecho" basename: $0 "# $0 indicates the shell script name echo" arg1: $1 "# shell parameters echo" arg2: $2 "Echo" arg3: $3"