Transferred from: http://www.jb51.net/article/56563.htmString interception of Linux is useful. There are eight ways.Suppose there is a variable var=http://www.aaa.com/123.htm.1. # Intercept, delete the left character, leave the right character.Echo $
Select is also a kind of loop, it is more suitable for use in the case of user choice.For example, we have one such requirement, after running the script, let the user go to select the number and then execute the command!#!/bin/bashselect Mysql_v in
String interception of Linux is useful. There are eight ways.Suppose there is a variable var=http://www.aaa.com/123.htm.1. # Intercept, delete the left character, leave the right character.The code looks like this: Echo ${var#*//}where Var is the
assignments and operations in the shell are string-handling by default, and here are a few special ways to do mathematical operations in the shell. In the future when you can see, hehe1. Examples of error methodsAVar=1+1Echo $varThe result of the
1. PrefaceAlmost half a year did not write a blog, wasted a long time, work in the chores too much, their own more and more lazy. In order to spur their own growth, or to insist on writing a blog, record their growth.2. Shell Function
1. Test SwitchSome test instructions are included in the shell, and the following table lists the meanings of these test instructions and whether they are available for the test command, bash, Ksh.
Switch
Test
Bash
Ksh
the assignment and operation in the shell is the string processing by default, here are some special methods of mathematical operation in the shell, which can be seen later, hehe1. Examples of error methodsAVar=1+1Echo $varThe result of the output
$$The PID of the shell itself (ProcessID)$!PID of the Shell's last running background process$?End code of the last Run command (return value)$-Flag at a glance using the SET command$*All parameter lists. such as "$*" in the Case of "" ", in the
1. Connect MySQL database The way to connect to a database in a shell is simply to specify a username, password, the name of the database to connect to, and then redirect to enter the MySQL statement as follows: Mysql-u username-p PASSWORD
function can make a similar custom execution command in shell script, the biggest function is to be able to simplify many of our program code. It is important to note that the shell script is executed from top to bottom/left to right, so the
A signal is a interprocess communication mechanism that provides an application with an asynchronous software interrupt that gives the application the opportunity to accept commands (i.e., signals) sent by other programs live terminals. After the
For automated operations, such as backup recovery, DBAs often need to encapsulate SQL statements into shell scripts. This paper describes several methods of SQL statements for shell scripts in MySQL database under Linux environment, for your
After the table is built by hash, the data volume of the table is 2048 large, how to verify the table is successful?Logical generate table name this part will not be written. As long as you can build the table successfully, this part of the script
Five, for security requirements each execution of the shell manually entered the password$ VI test5.sh#!/bin/bashEcho-n "Enter password for u_test:"Read PASSWDSqlplus-s/nolog Conn u_test/$PASSWDSELECT * from tab;ExitEof$ chmod +x
测试操作符
Common Test Operators
English name
Description
-F file
file
files exist and are normal files True, that is, test expressions are set
-d file
Direct Ory
DirectoryI. Condition selection: If statementTwo. Conditional judgment: Case statementThree. For loopI. Condition selection: If statement
Single Branchif judgment condition; thenBranch code with true conditionFiExample: Judging whether a number
If condition test statement
If-then-fiThe IF condition test statement runs the command after the if (judgment).If the exit status code for this command is 0, the command in the then section will be executed.If the exit status code for the
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.