In shell scripts, there are some common special variable representations that need to be known.Here are some of the frequently used special variable representations:$ Current PIN name$ ... Parameters of the incoming script or function (greater than 1
RPYC makes it easy to implement remote method calls, while Plumbum can implement a shell-like encoding in Python:The specific implementation code is as follows:server.pyImport rpycfrom rpyc.utils.server import threadedserverfrom plumbum import
1. Arithmetic operators2. Relational operators3. Boolean operator4. String operator5. FILE-related operatorsArithmetic operatorsThe bash shell does not provide any mechanism to perform simple arithmetic operations, but we can use some other programs,
Symbol
Meaning
;
Command delimiter
#
configuration file comments; Root user command terminal prompt
~
Home Directory CD ~
-
Previous Path CD-Su-linux Switching user
2. Correct method1) Use LetVar=1Let "Var+=1"Echo $varThe output is 2, no tragedy this time.Attention:A) I tested let almost support all operators, see an article on the internet said "let does not support + + 、--and comma, (,)", but after I test the
1. Perform the command locale view, which appears as follows:[[Email protected] ~]#localelang=ZH_CN. Gb2312lc_ctype="zh_cn.gb2312"lc_numeric="zh_cn.gb2312"Lc_time="zh_cn.gb2312"lc_collate="zh_cn.gb2312"lc_monetary="zh_cn.gb2312"lc_messages="zh_cn.gb2
1> file Comparison:-d filename checks if filename exists and is a directory-e filename checks if filename exists-F filename checks if filename exists and is a file-r filename checks if filename exists and is readable-s filename Check if filenmae
First, if else1.1, ifIf statement syntax format:if condition Then command1 command2 ... fiWrite a line (for the terminal command prompt):if [$ (PSgrep"ssh"1thenecho" True"fiAt the end of the fi is if the upside-down spelling, and later
in the In a Shell script, some operations that need to be reused are defined as public statement blocks, which can be called functionsWhat are the benefits of using functions? Make script code more concise, enhance readability and improve execution
Integer numeric Operations use the expr command: You can only do integer operations and return the calculation results by default Format:Expr integer 1 operator integer 2 ...Integer values can be supplied with variables, giving the result of the
1/ETC/PASSWD: User account information/etc/shadow: Secure user account information/etc/group: Group account information/etc/gshadow: Security group account information2ID: View the user ID and group ID of the current userId-u: Show only User IDId-u
Function Description: Execute commands on multiple servers in bulk1 #!/bin/bash2 3 # ==========================================4 #function: Execute commands on multiple servers in bulk5 #method:./batch_cmd_manager.sh 6 #return: List of results
First,ShellFour The Swordsman (grep)grep fetch rowsRegular Expressions:
[0-9] denotes character match 0-9{1,3} indicates that the number of matching characters is less than 3.
Example one:
[email protected]
Create a TXT file in the "/home/hadoop/" directory of your local Linux file system, where you can enter some words.mkdir hadoopcd Hadooptouch Test.txtgedit test.txt
To view the file location locally (LS)Ls-al
Displaying the contents of a file
Introduction of distribution System
When the business is bigger, the server needs more and more, a few servers is a bit better, when more than 10, dozens of, the workload is very large! And not specification, need a template machine to
Write a script in the Linux environmentFrom the keyboard to let the user enter several files, the script can archive this several files into a file:1. First introduce the CASE statement formatCase SWITCH invalue1)Statement...;;value2)Statement...;;*)
# # #10个实战及面试常用的shell脚本
Some considerations before writing the script
1. Start with interpreter: #!/bin/bash pre>
2. Syntax indentation, using 4 spaces, more attention to the description
3. Naming rules:
This is a shell script practiced hand program that exercises the use of a for statement#! /bin/bashn=0while read arr[$n] #通过键盘给数组赋值 ... The first element of the array is saved in arr[0] ... Enter indicates the input interval for the element, ctrl-d
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
[TOC]Shell functions and arrays one, Shell function 1.1 function format 1function name { commands}Example 1:#! /bin/bashfunction inp(){ //定义一个inp的函数echo $1 $2 $3 $0 $# }inp 1 a 2 b //传入参数 //传入参数Run
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