The following lists the common methods of $
$n represents the arguments passed to the script, representing the first one, and the second one ... $# represents the number of arguments passed to the script $0
ShellApplication TipsTips:1, command completion function: Key2, clear screen:ctrl+l3. Delete all contents before cursor:ctrl+u4. Command history: HistoricalThen:! History The command label listed, you can execute that command. Such as:! 188Also:
Method One:Modify the/etc/sysconfig/i18n fileChange the lang= "en_US" inside to GB2312.To restart the machine.Without restarting the method, directly# lang= "GB2312"And then we can.Modify i18n just to restart the activeMethod Two:#vi
1, mkdir newdir: New directory2. Touch filename: New file3. Vi/vim filename: Edit file4. grep [-ACIVN] [-A] [-b] [--color=auto] ' Search string | | Regular expression ' filename : A matching row was found from the file and displayed-A binary file
Tag: Shell
Hup (1) suspended, usually caused by terminal disconnection or user exit
INT (2) interrupt, usually caused by Ctrl + C Combination
Quit (3) exits, usually caused by Ctrl +/Combination
Abrt (6) abort, usually caused by some serious
Today, I wrote a shell monitoring script to monitor the running status of keepalived by combining the shell script with zabbix. The script name is check_keepalived.sh #! /Bin/bashunm = 'ps-Ef | grep keepalived | WC-l' if [$ UNM-GT 2]; then Echo 1;
When writing shell scripts, brackets and brackets are often used. I. Parentheses, Parentheses () 1. Single parentheses. ① Command Group. The commands in parentheses will open a new sub-shell for sequential execution, so the variables in parentheses
Simple shell script exercises
Simple Example
Conversation Script: The variable content is determined by the user.
[[Email protected] Scripts] # vi sh02.sh #! /Bin/bash # program: # user inputs his first name and last name. program
1. How to perform arithmetic computation in Shell
A = 1; B = 2
(1) Let C = $ A + $ B
(2) c = $ [$ A + $ B]
(3) c =$ ($ A + $ B ))
(4) C = 'expr $ A + $ B '(note the spaces before and after the operators)
2. Test Method
[Expression]
Entry Level
Entry level: strings like 1, 2, 3, 4, and 5
#! /Bin/bashvar = "1, 2, 3, 4, 5" Var =$ {var //,/} For I in $ var; do echo $ I; done
In this way, the results can be output.Shap level
In the preceding example, the split string cannot
I recently wrote a shell script, which has high efficiency requirements, so I read some articles. I feel that this article is really good. The example in this article is really great! Institute
Use me to extract them:
@ 1: instance:
Requirement:
Hbase is a distributed, column-oriented open source database. Its implementation is based on Google's bigtable theory and hadoop HDFS file system. Hbase is different from general relational databases (RDBMS ). Hbase is a column-based database
1. Define Variables
1) when defining a variable, the variable name does not contain the dollar sign ($), for example:Var = "Hello World"2) Note that there is no space between the variable name and equal sign, which may be different from all
Summary of statements in Shell integration:
If statement:
But the if statement of the Branch:
If []; then
CMD;
Fi
If statement for dual Branch:
If []; then
Cmd1;
Else
Cmd2;
Fi
Multi-branch if statement:
If []; then
Cmd1;
Elif []; then
Cmd2;
Elif [];
1. Echo Parameters
-N does not wrap (default line feed)
-E makes the transfer character valid
Example
Ss = 'abc \ n' echo-e $ ssabc # echo $ ssabc
2. When assigning values = do not include spaces on both sides
A = "hello" # error A = "hello"
3.
[[Email protected] shell] # Cat getopts. Sh
#! /Bin/bash
# Date = 2014-09-16
# Is to practice the getopts
While getopts "A: BC" Arg (: The preceding variable must follow the parameter)
Do
Case $ ARG in
A)
Echo "A's Arg: $ optarg"
;;
B)
Echo "B"
;;
C)
Shell upgrade,/bin/bash versions 4.1 to 4.3, bash4.3
Bash environment variables have arbitrary code execution vulnerability: "Using CGI requests can cause remote code execution, which in turn leads to server intrusion, causing serious harm,Patches
Getting started with Shell programming (second edition) (medium)Variable test statement-test
Purpose: test whether the variables are equal, empty, and file type.
Format:
Test condition or [] # range: integer, String, file
1) integer test:
Test
Basic Regular Expressions and shell Regular Expressions for Linux shell Programming
Fast query of Linux commands and Shell programming examples
Covers common Linux commands, including Shell script programming syntax, text processing
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service