First, the experimental stepsBasic usage of 1.shell variables and usage of common symbols(1) Change the main prompt to the user's home directory nameExport ps= $HOME(2) Assign the string DOS file c:>\ $student \* to the variable x and display it(3)
Shellgawkgawk Options
-f Specifies the field delimiter for delimited data fields in a row
-f Specifies the handler's script name
-V Var=value defining variables in the Gawk program
-MF N Specifies the maximum number of rows to
A shell function is a set of command sets or statements that make up an available block. Using functions can simplify scripting. The function requires that the function be defined and reused, and that it is used directly when calling the functions.
#!/bin/baship=$ (ifconfig eth0 |grep "inet addr" | awk ' {print $} ' |cut-f1-d ":") a=$ (df-h |grep/dev/sda2 |awk ' {print $} ' |cut-f1 -B "%") #截取分区使用率If [$a-ge] then echo "$IP the server root partition is about to have no space, please clean it up
1. Use the & symbol to execute commands in the backgroundYou can add the & symbol to the Linux command or script to make the command or script execute in the background, for example:.$./my-shell-script.sh &2. Use Nohup to execute commands in the
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
Scenario One: Modify environment variables for Linux serversWith Linux, there is a. bash_profile configuration file under the user root, which is only valid for the current user. Modify the/etc/profile file if it is valid for all usersUse the LS-A
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
1. ExercisesFind all files with the suffix. txt in the/123 directory
Bulk Modify. txt to. txt.bak
Package all. bak files into 123.tar.gz
The name of the batch restore file, that is, to remove the added. Bak again
2. Exercise
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
1. Date view modify system time and dateDate-DDisplays the time of the string description-FShow each line of time in the Datefile file-RDisplays the last modified time of the file-RDisplay time in RFC-2822 compatible date format-rfc-2822Display time
After MySQL installation on Linux uninstall is not clean, ping server ping does not pass the ICMP protocol is closed, Ping is using the ICMP protocol. Export is a global variable that all users can log in to use.Introduction to 1.iptables firewall
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
This is I learn to make notes or to make notes on their own easy to remember the format is very important examples are reference I also made the color on the impression notes to distinguish it on the top of it.
read for interactive scenarios
Shell Introduction
The shell is a command interpreter that provides interaction between the user and the machine
Supports specific syntax, such as logical judgment, looping
Each user can have their own specific shell
CentOS7
To master a language, you must first master its grammar. As in C, the shell has its own syntax.VariableAs a rule, shell variables usually begin with an underscore, consisting of letters, numbers, and underscores of any length. There are two types of
Start contacting the Linux command line to learn about the Linux file system navigation and the commands needed to create, delete, and process files.Note: At the end of the article there are benefits! Several shortcut keys:
Linux
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.