Sed tool "streaming editor"--Non-interactive, filter based on pattern matching and modify text--progressive processing and output of the results to the screen--can achieve the output of the text, delete, replace, copy, cut, import, export and other
Looping statementsThe looping statements in the shell are as follows:
for
while
unitl
case
select
For/while/unitl must end with done
forCycleforLoops are used to iterate through an array (data list) or
Exception handlingYou can use the Try/except statement to catch an exception.The try/except statement is used to detect errors in a try statement block, allowing the except statement to catch exception information and handle it.If you do not want to
2. process file 2.1 Create file TouchIf you want to change the access time only, you can use the-a parameter.$ ls-l Test_one-rw-rw-r--1 Christine Christine 0 may 14:35 Test_one$ touch-a Test_one$ ls-l Test_one-rw-rw-r--1 Christine Christine 0 may 14:
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,
One, pipe and operation control1. Pipe character: | (The result of the previous command output to the following command)Count the number of files after the ls command: LS |wc-lList the number of files in the/etc/directory: find/etc/-type f |wc-l2.
One, Shell command application exercises1. Describe the purpose of the following documents①/etc/passwdpasswd is a password file that is used to manage the user's password. Ordinary users can usually only modify their own password
#!/bin/bash #Write a script#1. Set the value of the variable file to/etc/passwd#2. Say hello to each user in/etc/passwd and say what the ID is.#shaped like:#Hello,root,your UID is 0. FILE=/etc/passwd COUNT= ' Wc-l${file}| Cut-f1-d" "` forIinch'
Op-ExpressionsThe expression is contained in or (()) or [] within,
An arithmetic expression:(())
((expression))
This expression is calculated according to the rules of arithmetic calculation. Equivalent to let expression .
Script[[email protected] shell]# vim for1.sh#!/bin/bashfor i in `seq 1 6`do echo $idoneExecution results[[email protected] shell]# sh for1.sh123456Script[[email protected] shell]# vim for2.sh#!/bin/bashsum=0for i in `seq 1 6`do echo "$sum
Case Base Syntax:Format case?? Variable name invalue1)Command;;value2)Command;;*)Commond;;EsacIn a case program, you can use the |, meaning, or means of a condition, such as???2|3)Command;;Script[[email protected] shell]# vim case.sh #!/bin/bashread
What is Shellshell?
Shell is a scripting languagecan use logical judgment, circular judgment and other statements;functions can be customized;A shell is a collection of system commands, such as a batch command of Windows;Shell script can
First, Shell script introduction
The shell is a program written in C that is a bridge for users to use Linux. The shell is both a command language and a programming language.
The shell is a scripting language;
Can use logic
VariableA variable is a named memory spaceAll variables in the shell are treated as character variables by default, and bash does not support floating-point variablesNaming rules for variables:You cannot make a reserved word in a program: for
1. ExercisesWrite a script that calculates the size of all processes in the Linux system and2. Exercise Analysis 2.1. First question, where to collect data for a processUse top or PS to get the memory usage size of each process. Once the size is
Recently, I was going to review the shell, just to see the shell operation, and to write a simple 99 multiplication table like a beginner. It is suggested that you can run shell scripts directly in
An environment variable 1 overviewThe bash shell uses a feature called environment variables to store information about the shell session and the work environment, which also allows false data to be stored in memory so that the shell can run
Array: A variable that stores a set of data and is able to manipulate one of the data in this set of data individually.Types of arrays: one-dimensional arrays, two-dimensional arrays, multidimensional arraysTypes of variablesThe default value of an
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