1, string judgment
str1 = str2 When two strings have the same content, length is true str1 != str2 When the strings str1 and str2 are not equal True-n str1 True when the length of the string is greater than 0 (string is not empty) -z str1 True when the length of the string is 0 (empty string) str1 True when the string str1 is not empty2, number Judgment
int1 -eq int2 The two numbers are equal to true int1 -ne int2 The two numbers are not equal to true int1 -gt int2 int1 is greater than int2 is true int1 -ge int2 int1 is greater than or equal to int2 is true int1 -lt int2 Int1 is less than int2 is true int1 -le int2 int1 is less than or equal to int2 is true3 file judgment
-r file user readable as true -w file user can be written as true -x file user executable True -f file for a regular file is true -d file The directory is true - the c file file is the character special file is true - the b file file is the block special file is true - s file is not true when the file size is non-zero -t file When the file descriptor (default is 1) specified device True for the terminal3, complex logic judgment
-a and -o or! NonHere are some use cases:
#!/bin/shmyPath=" ;/var/log/httpd/"myFile="/var /log/httpd/access.log"# The -x parameter here determines if $myPath exists and has executable permissions if [ ! -x "$ myPath"]; thenmkdir "$myPath"fi# The -d parameter here determines whether $myPath exists if [ ! -d "$myPath"]; thenmkdir "$myPath"fi# where the -f parameter evaluates $myFile Is there if [ ! -f "$myFile" ]; thentouch "$myFile"fi#Other parameters are also -n, -n is to determine whether a variable has a value if [ ! -n "$myVar" ] ;nenecho "$myVar is empty" Exit 0fi#Two variables determine whether they are equal [ "$var1" == "$var2" ]; thenecho '$var1 eq $var2'elseecho '$var1 not eq $var2'fi if list then do something here elif List then do another thing here else do something else here fi EX1:#!/bin/shSYSTEM=`uname -s` #Get the operating system type, my local is linuxif [ $SYSTEM = "Linux" ] ; then # if For Linux, print the linux string echo "Linux"elif [ $SYSTEM = "FreeBSD" ] ; then echo "FreeBSD"elif [ $SYSTEM = "Solaris" ] ; thenecho "Solaris"elseecho "What?" ;fi #ifend> Basically the same as other scripting languages. There is not much difference. But it is worth noting. The condition inside [] is judged. > ========================================================= ========================== $HOME/.bash_profilecd $HOMEsh .bash_profilecd $HOME/jnjzapp/sos_dx/echo -e 'Start'. /jn_card_dx.shwait#sqlplus $DBSTR <1, there must be a space between the 2 and [] and the judgment condition must also have a space between the 3,] and ; there can be no space between
This article will guide you to install Debian 7 Wheezy network directly by using DNSMASQ as a PXE se
How Linux extends the XFS file system. There is extra space on the disk, so I want to extend the exi
Yesterday I received the zabbix alarm email, the usage rate of a servers /home directory re
. Using a Linux terminal is more than just entering commands. After learning these basic techniques,
/etc/fstab file error, unable to enter Linux system
Ubuntu system gedit appears Chinese garbled two solutions
How to run the process in Linux
Linux/Unix simple shortcut summary
Ubuntu environment variable configuration file
Detailed use of rz and sz commands in Linux
VideoStudio how to export video? VideoStudio video file graphic tutorial
How to change keyboard input or keyboard language in win8
How Win8 makes reverse selection in folders
Windows 10 system rearranges the program in the start menu (normal method does not work)
Win8 association Sina Weibo to people application
Windows 8 system PPTP /L2TP settings detailed graphic steps
Windows 8.2 is expected to restore the full start menu function
Windows7 operating system basic tutorial Course 6: Minesweeper game (1)
How can I make the computer faster after reinstalling the system? (1)
Blade seven years of itching must be careful four major misunderstandings