Difference:1, two files are set environment variable file,/etc/profile is a permanent environment variable, is a global variable,/etc/profile.d/set all users to take effect, is also a permanent variable, is a global
ObjectiveToday, when writing a script, found that the previous phase used some of the usage is still need to go to Baidu Search, and find the answer also need to filter, delay writing script time, this article on the comparison between the string
Requirements: Use the shell to customize a variety of personalized alarm tools, but the need for unified management, standardized management.Idea: Specify a script package that contains the main program, subroutine, configuration file, mail engine,
The shell script has strict rules for spaces, and there must be no spaces on either side of an assignment statement, and a string comparison with spaces on both sides of the equal signWhen assigning: I=1i=$ ((i+1))//= must not have spaces on both
1. basic usage of shell variables and usage of common symbolsThis section requires writing out the shell commands that implement the requirements , showing(1) Change the main prompt to the user's home directory name( Hint: reference material 4.6.8
1,$$: Displays the current process ID number[Email protected]:~/linux/shell/how_to_use_var$CatShow_pid.SH #!/bin/BashEcho $$Sleep the[email protected]:~/linux/shell/how_to_use_var$ bash show_pid.SH&[1]9401[email
1, SH and./The Difference[email protected] ~]# cat test.shEcho I am thzzc1994[Email protected] ~]# sh test.shI am thzzc1994[Email protected] ~]# bash test.shI am thzzc1994[Email protected] ~]#./test.sh-bash:./test.sh: Insufficient permissionsWant to
Deny remote illegal users with SSH brute force login server. Once you enter the password error four times, directly deny the host IP login.The script is as follows:
#!/bin/bash#auto Deny SSH error IP#author is Lingshu#2018-04-30#########
8.6 Pipe symbol and job control8.7/8.8 Shell variables8.9 environment variable configuration file
8.6 Pipe symbol and job control
1. Pipe Symbol | Pass the result of the preceding command to the following commandFor example, # cat
Pipe character and job controlPipe characterThe pipe character means that the output from the previous file is passed to the following command. To display the number of files in the current directory:`Job ControlCtrl Z pauses the current task (can
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
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. In most cases, UNIX system commands accept input from your terminal and send the resulting output back to your terminalThe list of REDIRECT commands is as follows:2. Output redirection: Redirects are generally implemented by inserting specific
While and for are circular statements, relative, the For loop uses a bit more. But the while loop is especially useful when reading a file line.While formatwhile [ 条件 ]do 内容done
Example: Determine if I is small and equal to 5, if less than
Exercise 1:Print a line with only one numberRequirements: title, a text document with only a number of lines to print outReference Answer:#!/bin/bash# date:2018 March 16 f=/etc/groupline= ' wc-l $f |awk ' {print $} ' for L in ' seq 1 $line ' do n= '
When we learn is the first to realize that we learn the shell is used to do what, it and other programming languages are different and advantages, do not blindly study, and finally do not know what the purpose of learning shell is to do. Let's start
Shell syntax Shell performs command operation
When the shell reads the input, it performs a series of actions. If the input represents the beginning of a comment, the shell ignores the comment symbol (' # ') and the remainder of the line.
1. String length:Var=123abc456echo ${#var}9expr length $var 92. Specify character interceptionEcho ${var:5} #截取前五个字符c456echo ${var:2:5} #截取第2到第5个字符3abc4echo ${var: 3} 3 characters after intercept (with space on the left) 4563. Interception of
Arrays are not used very often in the shell, but are very useful, let's take a look at some of the uses of arrays in the shell:
Define array a= (1 2 3 4 5); Print array echo ${a[@]}The contents of the array can be either numbers or letters, as
How can I implement real-time alarm functions through shell scripts and enterprises ?, Shell Information
At work, we will have some applications running on the server online, so these applications have problems. For example, after the memory and CPU
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