Basic composition:find pathname-option [-print-exec-ok ...]Classify the attributes of the memory parameters ~Pathname: Specifies the query root path of the find command, such as '/', './'.You can also specify the search path in the-path
View Catalogawk ' {if (!system ("test-d")) print $} 'Batch Quick Create user for in user{0.. Ten Do useradd $i echo123456passwd --stdin $i DoneUse the IF statement to determine#!/bin/bash# file Judgmentif[-E $1]; Then Echo "File
First shell script# VI test.shAdd the following:#!/bin/bashecho "Hello World"#! is a contract tag that tells the system script what interpreter to execute, which Shell to use.The echo command is used to output text to a window.There are two ways to
File Comparison characters-e filename true if filename exists [-e/var/log/syslog]-D filename True if filename is a directory [-d/tmp/mydir]-F filename True if filename is a regular file [-f/usr/bin/grep]-L filename True if filename is a symbolic
1. TopicsWrite a script to determine whether the 80 port of the machine (assuming the service is httpd) is open, if it is open to do nothing, if the discovery port does not exist, then restart the httpd service, the concurrent mail notify yourself.
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
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