Excerpted from http://www.comptechdoc.org/os/linux/usersguide/linux_ugshellpro.htmlTestsThere is a function provided by bash called Test which returns a true or False value depending on the result of the tested Expression. It syntax is:Test
Judgment file:Workdir=/home/tmplocal_list_file= $WORKDIR/local.list#if no Local.txt file, generate a new oneif [!-F "$LOCAL _list_file"]; ThenTouch $LOCAL _list_fileFiNote: Be sure to have a space, to determine whether the file exists, if it does
If condition judgment1. Basic syntax:if [command]; ThenStatements that meet the criteria for executionFi2. Extended syntax:if [command];thenStatements that meet the criteria for executionelif [Command];thenStatements that meet the criteria for
Http://wenku.baidu.com/link?url=9Q9VU54XuvlN77urP1zwOLVMMrS2EFNx4HcvFizdPl-zQy3K_ Ipd3o-mdu4sbihezumnq0blbwhusuaol_y6quvkxtgjiaem9gq9i-jb5_e Shell in the condition to determine if in the-Z to-D meaning 2011-09-05 [-a file] if the file The existence
Shell if judge commonly used in the green part, the tail part of the more do not understand. Reproduced from Baidu Library.
[-A file] if FILE existence is true.
[-B-file] True if file exists and is a block-specific file.
[-C file] is true if file
[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E File] True if file exists.[-F file] True if file
[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E File] True if file exists.[-F file] True if file
If statement format:If condition then statements [elif condition then statements ...] [Else statements] fiThe syntax for the most streamlined if command is:if TEST-COMMANDS; then CONSEQUENT-COMMANDS; fiThe IF condition judgment statement
This article mainly introduced the shell script if condition judgment and the judgment condition summary, this article first gave the IF condition judgment the grammar, then gave the commonly used judgment condition summary, needs Friend can refer
Objective:no matter what programming language is inseparable from conditional judgment. The shell is no exception.
Copy Code code as follows:
If List Then
Do something here
Elif List Then
Do another thing
Else
Do something
Java EE Development of various types of resources download list, the history of the most complete IT resources, personal collection summary.
Objective:
No matter what programming language is inseparable from conditional judgment. The shell is no
Startup script start.sh This script is used to start the project, log logs and PID#!/bin/shprg=" $" #$ A represents the current startup script # Get the true path of the file while[-H"$PRG"]; Dols= ' Ls-ld"$PRG"' link= ' Expr"$ls": ' .*-> \ (. *\) $"
The shell condition determines if the-Z to-D meaningShellfilestringless Terminal user[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if
From: http://m.jb51.net/article/56553.htm This article mainly introduced the shell script if condition judgment and the judgment condition summary, this article first gave the IF condition judgment the grammar, then gave the commonly used judgment
by Francis_hao Oct 1,2017This article extracts the Man Handbook from bashConditional expressionsThe conditional expression is composed of a composite command [[or] built-in command test and [used for testing file properties and string or numeric
The shell condition determines if the-Z to-D meaning[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E
[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E File] True if file exists.[-F file] True if file
[ -a file] is true if file exists. [ -b file] True if file exists and is a block special file. [ -c file] True if file exists and is a word special. [ -d file] True if file exists and is a directory. [ -e file] is true if file exists. [ -f file]
[] and test
Both are the same, and the test expr and [expr] have the same effect on the command line.The three basic functions of test are to judge a file, judge a string, and judge an integer. Supports the use of "and or not" to concatenate
[-A file] is true if file exists.[-B file] True if file exists and is a block special file.[-C file] True if file exists and is a word special.[-D file] True if file exists and is a directory.[-E File] True if file exists.[-F file] True if file
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.