1, determine whether a number is in the one-way.#!/bin/Bashread-P"pls input a number:"N Case "$n" inch 1) Echo "variable is 1" ;; 2) Echo "variable is 2" ;; 3) Echo "variable is 3" ;; *) Echo "pls input a number between 1 and 3"exit;Esac2, multi-level if statement rewriting#!/bin/Bashread-P"pls input a number:"Nif[$n-eq1]; Then Echo "$n is a variable 1"
If the Case statement is not executed, let's see why .... -- Linux general technology-Linux programming and kernel information. The following is a detailed description. Today, I wrote a simple shell script to test the case statement and found a strange phenomenon. The procedure is as follows:
#! /Bin/sh
Echo 'hit a
Branch statements:if else if else; switch case--How to use if else if else:Console.WriteLine ("Please Punch");--Output "please punch"int a = Convert.ToInt32 (Console.ReadLine ());--Define a variable aRandom i = new random ();--Random numberint x = I.next (3);--variable x can be randomly given a number of 0-3if ((a-x = = 1) | | (A-x = =-2)){Console.WriteLine ("PC =" + x);Console.WriteLine ("Man wins");}else if (x==a){Console.WriteLine ("PC =" + x);Cons
= $tmpElseIf [$tmp-gt $max];thenmax= $tmpelif [$tmp-lt $min];thenmin= $tmpFiFiDoneecho "The Max Random is: $max"echo "The min Random is: $min"[Email protected] ~]#
Case statement: Select structureCase switch in (switch is a value)value1)Statement...;; (The statement ends with a double semicolon)value2)
Statement:Branching statements: if,if else,if ElseIf else,switch caseLooping statements: For,while,do While,foreachJump statement: Break,continueException statement: Try Catch finallyBranch statements:int a=5;if (a>0){Console.WriteLine ("This is a positive number");}Esle//If the a{Console.WriteLine ("This is a number less than or equal to 0");}else if (a>10){Console.WriteLine ("This is a number greater than
OR OR or expression) after the statement to query out, all Stateid = 10 and (s Records of tateid=20 and UserID = 2)*/ SELECT * fromTb_test_reportWHEREStateidinch(Ten, - ) and( Case whenStateid= - andUserid 2 Then 0 ELSE 1 END)= 1 The key to this type of problem is
Case w
inflexible.Report Development Dimension ReferenceThe following dimensions borrow a report developed by Finereport to showDaily Money PlanDaily Funding Plan Dimension report development requires several key points to note:1. Date Lock2. column header pinning: Prevents too many column names, the item name cannot be found on display, and the header needs to be fixed to prevent too many project names from being found when the report is pulled down. 650) this.width=650; "src=" Http://s4.51cto.com/wy
The syntax for a case when statement in SQL is as followsSimple Caseexpression: Caseinput_expression whenWhen_expression ThenResult_expression[. .. n] [ELSE else_result_expression] ENDsearched Caseexpression: Case whenBoolean_expression ThenResult_expression[. .. n] [ELSE else_result_expression] ENDWhere result_expression is supposed to be an arbit
Select Case is a condition to choose his advantage is the only export, a lot of time he is much better than if else oh.Select1%>
The syntax for the SELECT statement is as follows:Select Case ExpressionCase Label_1Statements_1Case Label_2Statements_2...Case ElseStatements_nEnd Select
For more details please see: htt
) b where a date=b. Date We might as well review the syntax of case.Case when there are two uses, one is similar to the example in the above simple cases function:Result ' wins '1' negative '20END There is also a case search function:Result=' win '1result=' Negative '20END Where result= ' wins ' can be replaced by other conditional expressions. If more than one case-when expre
change the color of a font with a case statement#!/bin/Bashcolor () {Red_color='\e[1;31m'Green_color='\e[1;32m'Yellow_color='\e[1;33m'Blue_color='\e[1;34m'Pink_color='\e[1;35m'RES='\e[0m'if[$#-ne2];then Echo"Usage $ content {Red|yellow|blue|green}"Exitfi Case " $" inchRed|RED) echo-E"${red_color}$1${res}" ;; Yellow|YELLOW) echo-E"${yellow_color}$1$
I. Basic Format of the case statement:
Variable
In the preceding format, the semicolon ";" after each mode indicates the end mark of the mode. The statement after the system execution mode does not bypass this flag.Ii. Use case statements to process option Parameters
!/bin/.====== [ $# -gt “$
the next set of patterns. Using;; in place of;; Causes the shell to test the nextThe pattern list in the statement, if all, and execute any associated list on a successful match. The exit status is zero if no patternMatches. Otherwise, it is the exit status of the last command executed in list.
Look at the following code:
Copy Code code as follows:
[Root@station1 ~]# Cat case.sh
#!/bin/bash
While:
Todo
Echo-n "Input a Lette
Sometimes a long if statement makes a program very difficult to read, and with a case, you can make the case statement more conciseThe case syntax is in the following format:Case expression inpattern1) suite1;; PATTERN2) Suite2;; ... patternn) Suiten;; *) Other_suite;; EsacP
specified user
BaseName directly obtains the file base name, cannot take the directory name of the command itself, the script itself executes script when the script path base name
Mail:echo "Mail Content" | Mail-s "Mail name" (root or send mail to other users)
Generate random Number:
RANDOM: Variable within range 0-32768 ($RANDOM)
Case
Case $ variable in
value1)
Tags: looping syntax Select result instance out Lin style outputCase Loop statement:1: GrammarThe basic form of a case statement is:Case SelectorWhen Expression1 then RESULT1When Expression2 then RESULT2When Expressionn then RESULTN[ELSE resultn+1]END;2: ExampleDeclareV_annum char (1): =upper (' nom ');V_appression VARCHAR2 (30);BeginV_appression: =
One. Select the day of the week with switchIn this case, for example: case= "Monday"Two. Use switch to select simple numbersIn this case, for example: case= ' 1 'Three. Use switch to select a value that has the function appliedExample: Switch (Preseint (GRADE/10)) {Case=6:do
Analysis of two methods of SQL statement row/column conversion case... the application of the when function and the limit function bitsCN.com
/* Create a database */Create database tmpGoUSE tmpGo
/* Create a database Test table */Create table [Scores]([ID] int identity (1, 1)Primary key,[Student] VARCHAR (20 ),[Subject] VARCHAR (30 ),[Score] FLOAT)
Go
Truncate table Scores/* Insert database test data inform
Swtich case must be used with break.Random r = new Random ();int a = R.next (1, 4);//A random number of playersint B = R.next (1, 4); Player B Random numberstring x = "", y = "";Switch (a){Case 1:x = "Scissors";BreakCase 2:x = "Stone";BreakCase 3:x = "cloth";BreakDefaultBreak}Console.WriteLine ("A contestant out" + x);Switch (b){Case 1:y = "scissors";BreakCase 2:
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.