Case-then the previous caseWant to bulk delete all users created in the previous caseScript Show: (Next time explain)#!/bin/bashecho > userlist.txt;for i in `seq 50`do id student$i >/dev/null 2>/dev/null; [ $? -ne 0 ] && echo -e "[\033[31merror\033
1, write the script/root/bin/createuser.sh, to achieve the following functions: Use a user name as a parameter, if the specified parameter of the user exists, it will show its existence, otherwise added; Displays the ID number of the added user and
I. Review exercisesGeneral wildcard charactersCurly Braces {}Inverted quotes, single quotes, double quotesoutput redirect > >>Enter redirection User-defined variablesTwo shell command exercises(1) The use of the following documents is briefly
Use of function functions for shell scripts? The basic things in front of the introduction, the following we introduce the function how to use.? Note: The function needs to be declared before it can be used.? The declared keyword can be used with
file Expression-e filename true if filename exists-d filename If filename is a directory, true-F filename True if filename is a regular file-L filename True if filename is a symbolic link-r filename If filename is readable, true-W filename if
In addition to being an interpreter, the shell is a high-level programming language with variables, keywords, and a variety of control statements.Command historyHistory displays a list of historical commands, including its ownHistory 50 shows the
recently, the company added 40 servers for the last active function, although the server can be managed by saltstack (automated operations Tools Saltstack), the project can be released through Jenkins + Saltstack (using jenkins+ Saltstack+sh deploy
first, the contents of the experiment1. Practice command history, aliases, and special character usages in the shell (4th. 4.2, Section ~4.5)2. Shell command application exercise (see Experimental steps)3. Write a shell script that executes in 4
Pipe character and job control
| Give the result of the previous command to the following command processing.[[email protected] ~]# cat 1.txt |wc -l 统计行数5[[email protected] ~]# cat 1.txt |grep ‘aaa‘aaaa 剪切出aaa的行
CTRL Z pauses a task,
1. List of files and directories 1.1 more common Linux top-level virtual directory names and their contents:
Directory
Use
/
The root directory of the virtual directory. Files are not usually stored here
Locate command1.locate filenameFuzzy match as long as the file name contains the keyword can beNon-real-time lookup, faster than find.Rely on index database/var/lib/mlocate/mlocate.dbAutomatically run once a day to update the database.UpdateDB
Recently around here for a long time ah, now reluctantly come out, share a little understanding of their ownExit statusA program once run must have only two kinds of results, either success or failure, the result of success is the same, the reason
Case one:Monitoring Web Site Directory ( /var/html/www ) If all files are tampered with (the contents of the file have been changed), if there is a file name (e-mail) to print the changes, the scheduled task every 3 minutes to execute onceMonitoring
1. Unlike Java, PHP and other languages, SH's process control is not empty, such as (the following is the PHP Process Control notation):You can't write this in Sh/bash, and if the Else branch doesn't have a statement execution, don't write this else.
Write a simple alarm system with the shell
Create a directory structure
mkdir -p /usr/local/sbin/mon/{bin,conf,shares,mail,log}mon //主目录bin //主程序目录shares //子程序目录mail //发邮件目录log //日志目录Program Main entry
CGI according to the definition of Baidu Encyclopedia, as follows:CGI is the specification of external programs when the Web server is running, and programs written by CGI can extend server functionality. CGI applications can interact with the
1. Special symbolsFor more information, see2, about the pipe character(1), cut split-D delimiter-F Specify segment number-C to specify the first characterFor example, see,Example, | Output, cut splits out the desired results later. In general,-C and-
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