OutFile is forbidden, or written files are intercepted;Operations in the database are as follows: (must be root permission)Show variables like '%general% '; # View Configuration Global general_log = on; # turn on general log mode Global
One, for loopThe For loop structure is a very frequent loop structure used in daily operation and maintenance work.1. For loop specific format:for 变量名 in 循环条件; do commanddoneThe "loop condition" here can be a set of strings with numbers
Requirements: Remove the IP field from the log and sort the statistics. General use awk command if the IP address is the first field thenawk ' {print '} ' filename |sort |uniq-c|sort-nrWhat if it's not the first field and there are several
The case selection statement in the shell script can be combined with the read instruction to achieve a good interactive response operation, case receives one or more parameters passed in by the read instruction, and then the case is selected
Cat Head Tail grep Sed awk Cut WC Sort Uniq TR TAC Rev Cat, Concatinate, connects the contents of one or more files sequentially, outputting them to the standard output.Cat 12.pub Cat-n 12.pub Cat-a file # Merging filesCat 12.pub 13.pub 14.pub
Mans Bash1. How the Shell works (1)Kernel Shell UsersParent Process Fork---waitChild process Exec--exitRelated Man documents:Fork (2)Clone (2)Execve (2)Exit_group (2)EXIT4 (2)Strace (1)-->strace-e2. Shell Syntax (2)1. Simple command (kw:simple
1.FOR Loop structure 1.1 for loop structure syntaxGrammar:For variable name in variable Value listDoInstructions...DoneTip: In this structure, "in variable Value list" can be omitted, when omitted is equivalent to in "[email protected]", using for I
Tag: while void \ n Const floor How long def lengthTopicBriefly:
There is a shell of length n, divides it into several segments, gives the number of schemes divided into each length, and asks how many kinds of partitioning schemes
1. Like other languages, the shell can also contain external scripts, which makes it easy to encapsulate some common code as a standalone fileExample: The testshellfileinclude.sh script is as follows:the #!/bin/Bash#shell file contains the following
This article: Determine whether the user input parameter is a numberHow is the calculation done in the shell?
Way One
[[email protected] scripts]# echo $((1+2)) 3
Way Two
Note: When using the method two, the requirements
In general, case is a judgment statement that is easier to understand than if.Case Statement Formatcase in 变量 值1) 内容 ;;值2) 内容 ;;esacNote: Each content needs to be added after;; , can be written across rows or peers.
Instance: Executes
1. Why use a functionLook at the role of aliases first[[email protected] ~]# alias httpd=‘/etc/init.d/httpd‘[[email protected] ~]# httpd start正在启动 httpd: [确定]function is to call the program multiple times the same code part is defined as a copy
Shell script advanced One, Shell script advanced condition test
When you write a shell script, you often need to judge some conditions, and you can use Test command test to help complete the test process. The test command tests whether a
Shell: is an outer layer of the kernel Protection tool, and is responsible for the completion of user-to-kernel interaction;Provides an interface for users to interact with the kernel, which receives commands entered by the user and sends it to the
Exercise 1:Monitor network cardrequirements: every 10 minutes to detect the specified network card traffic, if the network card traffic is 0, restart the network card! (Use cron Task Scheduler!) )Reference Answer:#!/bin/bash# date:2018 March 21 lang=
If statement1. What is a conditional test operation?To make a shell script "intelligent", the problem is to differentiate between different situations to determine what action to take. The shell environment, based on the return status value ($?)
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