Shell BasicsFirst, Shell Overview1) The Shell is a command-line interpreter that provides the user with an interface system-level program that sends a request to the Linux kernel to run the program, allowing the user to start, suspend, stop, or even
1 if statementThe format of the IF statement:If condition then command fiIf condition then command else command fiIf condition then command elif condition then command else command fiExample:Determines whether the current user is root, and if so,
To the basic structure of the For loop:The condition of the for variable name in the loop;CommandDoneExample 1[email protected] ~]# cat for1.sh#/bin/bashFor i in ' SEQ 1 5 ';d oEcho $iDoneThe "condition of the loop" here can be written as a set of
1, realize the bulk add 20 users, the user name is user1-20, password is user+123#!/bin/Bashcount=$1if[-N"$count"]then for((i=1; i)) DoUseradd-d/home/user_$i-s/bin/bash user_$i; Echo User_"$i"123|PASSWD--stdin user_$i; DoneElseEcho"$count is
There are three main steps to completing tasks and monitoring manually:1. mission_cron.php (timed automatic task script):PHP /* * * Automatic task timer (5s execution). * Swoole_timer_tick resolution of second-level timing; * To adjust, note the
Bash Script Programming:Case statement:Multi-Branch If statement:if CONDITION1; ThenBranch 1Elif CONDITION2; ThenBranch 2...else CONDITION; ThenBranch NFiExample 1: Display a menu to the user;CPU) Display CPU informationMEM) Display Memory
Functions: functionProgram Programming: Code ReuseModular programmingStructured programmingThe code of an independent function as a whole, and a name for it; a named code snippet, which is a function;Note: The code snippet that defines the function
What the shell means: First, the Shell's English meaning is "shell"; It is relative to the kernel, because it is proposed to be based on the core of a user-oriented form of expression, such as we see a ball, see its shell, rather than nuclear.
Shell Command CollectionCCat Zdd Browse the contents of a ZDD fileCat Zdd1 Zdd2 Browsing the contents of multiple filesCat-n ZDD Browse the contents of a file Zdd and display line numbersCD back to the start directory, that is, just logged into the
$? is used to determine whether the previous command has performed successfully.If the return is 0, the execution succeeds and fails if it returns to a different value.650) this.width=650; "Src="
For example, there are the following files Test.txt1 134.102.173.432 134.102.173.433 134.102.171.424 134.102.170.9To count the most frequently occurring IPs, you can take advantage of the following shell script:Cat Test.txt | awk ' {print $} ' |
One of the basic features of bash:Command history: The shell process saves commands that were previously executed by the user in its session;~]# historyThe ability to customize the history can be achieved through environment variables:The number of
I. File systems and Securitychmod commandThe chmod command has two modes, one is the symbol mode, executes the user with the Ugo, executes the permission with the RWX, the other is the absolute mode, uses the different value of the octal different
The basic features of bash:Command completion:The shell program receives a request from the user to execute the command, and after the analysis is completed, the leftmost string is treated as a command;Command Lookup mechanism:Find internal commands;
1, when the script is run to specify parameters, directly behind the script name to follow the parameters to be added, in the process of running, "$" represents the program name, "$" represents the first parameter, the second parameter, the Nineth,
(1) Replace one or more spaces in the text with commasThe text reads as follows:# Cat Text1 2 2 3 3 + 4 4 2 4(2) The Shell program code is:# Cat Text | Sed ' s/[' []*/,/g ' 1,2,42,2,3,43,3,44,4,,4,,2,4Script Description:
sRepresents the
1. Shell Overview1.1 Shell Introduction(1) The shell is a command-line interpreter that provides users with an interface system-level program that sends a request to the Linux kernel to run the program, allowing the user to start, suspend, stop, or
Position variable.$ $ Gets the file name of the currently executing shell script.[Email protected] ~]# vim 0.sh[email protected] ~]# cat 0.shEcho[[Email protected] ~]# sh 0.sh0.sh[Email protected] ~]#
If I put it in the full path, it will.
1. String judgmentSTR1 = str2 When two strings have the same content, length is trueStr1! = str2 True when string str1 and str2 are not equal-N str1 True when the length of the string is greater than 0 (string non-null)-Z str1 True when the string
[email protected] ~]# split [-BL] File PREFIXParameters:-B : Can be divided into the file size, can be added units, such as B, K, m, etc.;- L : Split by number of rows.Example:Example One: my/etc/termcap has more than 700 k, if want to divide into 30
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.