Substitution of 1,shell variablesVariables can be replaced by a specific value depending on whether the variable is empty or deleted${var} variable Original value$ (Var:-word) If the variable is empty or has been deleted then return to Word, but do
Function: Extract various fields from the output of the input file or commandUsage: cut–c{string range}–d{field separator}–f{field index number}Example:(1) View online users: Who | Cut–c1-8(2) List of user names obtained from System file/etc/passwd:
Operations, shell scripts often encounter the legitimacy of determining the value entered, such as IP, email address, and so on. Then, according to their own script to summarize the judgment of IP legitimacy script to share to the netizen, when
Instance one: monitors the specified file status in the mounted directory, polls for one second, and the file is updated to be taken to the specified directory.1 #########################################################################2 #File
One. HDFs shell commandWe all know that HDFs is a distributed file system to access data, then the operation of HDFs is the basic operation of the file system, such as file creation, modification, deletion, modify permissions, folder creation,
StatsTo view the basic commands for the memcached status, this command allows you to see the following information:STAT PID 22459 Process IDSTAT uptime 1027046 server running secondsSTAT time 1273043062 Server current UNIX timestampSTAT version 1.4.4
The shell can often be seen: >/dev/null 2>&1/dev/null represents an empty device filewhere does the > delegate redirect to, for example: echo "1111" >/home/a.txt1 means stdout standard output, the system default is 1, so ">/dev/null" is equivalent
[ -a file] is true if file exists. [ -b file] True if file exists and is a block special file. [ -c file] True if file exists and is a word special. [ -d file] True if file exists and is a directory. [ -e file] is true if file exists. [ -f file]
1, case do with the execution of the option script:#!/bin/bashCase $ inXecho "X is selected";;*)echo "Please use X"EsacSecond, case combined while doing interactive script:#!/bin/bashWhile TrueDoRead-p "Enter Port of Chaoxingdata (d,1):" PortCase
The replacement function of SED is quite similar to the VIM syntax.Replace 1 to 10 rows of Nologin with login[[Email protected] ~]# sed ' 1,10s/nologin/login/g '
First, expect explanation
Expect allows us to automatically log on to remote machines, and can implement automatic remote execution of commands. Of course, if you use key authentication without a password, you can also implement automatic
Shell Script IShell There are two ways to execute a command:
Interactive (Interactive): Explains the execution of a user's command, the user enters a command, and the shell interprets the execution of a single rule.
Batch: The user
Create multiple user groups and users, set up candidate groups, default shellgroupadd-g 40000 adminuser specify GIDUseradd natasha-g adminuser Specify a subordinate group[Email protected]/]# Useradd Harry-gadminuser[Email protected]/]# Useradd sarah-
Purpose: Self-collation, self-review, self-reflection!Content: Dry Goods! Dry!! Dry!!!Attach: The shortcomings of the hope that you correct, can give like me rookie a little inspiration is the best. Just the inspiration ...Thank you: Thank the old
7. If you judge some special usageIf [-Z $a] This indicates what happens when the value of variable A is emptyIf Grep-q ' 123 ' 1.txt; Then what happens if the 1.txt contains a ' 123 ' rowif [!-e file]; Then what happens when the file doesn't
Knowledge Point Grooming: Click the link to enter1. Shell Introduction and variables, scripting related concepts2. Bash Programming: Condition testing3. Bash Programming: arithmetic operations4. Bash Programming: If statements5. Bash Programming:
Shell Learning Notes# #变量# #普通变量:EG1:Name=axeEcho $nameps. equals two times cannot have a space, otherwise it will be an error.EG2:Name= "Axe Prpr"Echo $nameOrName= ' Axe PRPR 'Echo $namePS. Double quotes can refer to other variables, single
Judging variablesRead-p "Input a word:" WordIf [!-n "$word"] ; thenecho "You had not input a word!"Elseecho "The word you are input is $word"FiJudging input parameters#!/bin/bashif [!-n "$"]; thenecho "You had not input a word!"Elseecho "The word
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.