Daily Shell Exercises (03)

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

Special usage in bash shell

1 ${bash_source-$0}Represents the full path of the currently executing script.2 cd-p enters with physical path/usr/localhadoop now chains to the/home/houzhizhen/usr/local/Hadoop/hadoop-2.72

How shell scripts are executed

method One: Switch toShellthe directory where the script is located (at this time, called the working directory) executesShellScript:Cd/data/shell./hello.shThe./ means to execute hello.sh under the current working directory . If you do not add

The second week of Linux learning; shell programming

Pstree-p #显示进程编号 (tree) echo $$ basic structure of #显示当前shell进程编号   scripts: #! Shebang (indicates what shell is used to open a file, typically using bash) configuration_variables #定义变量FUNCTION_DEFINITIONS # define function Main_code #主要执行命令  

The use of if,case,for in shell scripts

DirectoryI. Condition selection: If statementTwo. Conditional judgment: Case statementThree. For loopI. Condition selection: If statement Single Branchif judgment condition; thenBranch code with true conditionFiExample: Judging whether a number

Linux Shell daemon/RAC Restart script

To establish a daemon process:#! /bin/sh PRO_NAME=./xxxx.sh while true ; do #用ps获取$PRO_NAME进程数量 echo ‘‘> nohup.out NUM=`ps aux | grep -w ${PRO_NAME} | grep -v grep |wc -l` #echo $NUM #少于1,重启进程 if [ "${NUM}" -lt "1"

Automatically log on to the server shell script

#!/bin/bash#Description: Auto Login The remote server#Author: Majinxu#Version: 1.0#CreateTime: 2018-3-012 18:34:41User= "Majinxu"Passwd= "! Ieric1234 "host_list= ("st1.qa.bj2.yongche.com""St2.qa.bj2.yongche.com""St3.qa.bj2.yongche.com")#seletc the

Using the shell to do the Nginx log analysis

#!/bin/bashif [[$# = = 0]];thenecho "Error: Please enter the number of days to query???"Elseecho "Temporarily does not support the 7 version of CentOS!!! "now_time_cuo=date +%s((end_time_cuo=${now_time_cuo}- echo $1*3600*24 | bc ))Now_time=date |

Shell Exercises (vi)

Exercise 1:Enter a number to execute the corresponding commandRequirements: Enter a number and then run one of the corresponding commands. The commands shown are as follows: *cmd meau* 1-date 2–ls 3–who 4–pwd; when input 1 o'clock, run date, enter 2

Shell shortcut keys

Shell--Unix--Bourne shellBash--linux--Bourne againShellCommand parser function:0 go to specify a path to search for user-entered commands0 environment variable--Path1. command or directory completionShortcut key: Tab1.2. Traverse History

Linux timed Execution Shell script command crontab

Crontab can execute a shell script and execute a series of Linux commands at a specified timeExample: Server administrator regularly backs up database data, logs, etc.DetailedCommon commands:Crontab–e //Modify the crontab file, if the file does

Shell Programming------Function Application

1. The return value of the Shell function:In general, a return of 0 indicates a successful run, and a non-0 return indicates a failure. For a view of the return value, use the $? command.2. Incoming parameters for Shell functions:Use the location

Use of the SED command in the shell

The SED stream editor is also a command in Linux that is often used in the shell to modify the contents of a file in a non-interactive way. The SED handles the text in rows, that is, one row at a time.The basic format of the SED command is:sed

About shell input and output redirection

The following is a syntax format for input and output redirection Two overview Output input redirectionGreater than sign >: Indicates output redirection (overwrites the original file)Less than Double greater than sign >>: (indicates output

CentOS7 next shell script that exploits security day to firewall and prevents brute force

#!/bin/bash#第一次运行创建记录文件-f 1.txt || touch 1.txtwhile :do #查看日志中登陆失败的ip次数超过10次的用户ip fip=`awk ‘/Failed/{ip[$11]++;}END{for (i in ip){if (ip[i]>10){print i}}}‘ /var/log/secure` #循环取出登陆失败超过十次的ip进行处理 for i in $fip do #查看处理记录文件如果该ip没有存在处理记录中说明是没有处理过该ip

Use of the expr operator for the shell

Note Using expr:The operator and the number used for the calculation have at least one space around it, otherwise the errorWhen using multiplication sign, a backslash must be used to mask its specific meaning.An enterprise-class case study of

NOTES: Linux--First knowledge shell

One: Word accumulationCurrent: currentlyDirectory: Directories Entries: ArticlesDefault: DefaultsInformation: InformationFormat: FormattingIgnore: NeglectLicensing: LicensingTwo:1.GNU Bash Description: The shell is the user interface of the Linux

Shell Script--Find command for file lookup

The first is to find the file name by using a-name parameter.Query for files ending in. txt, and files that begin with T :[Email protected]:~/test$ lsone.txt three.txt two.txt[email protected]:~/test$ Find/-name ' *.txt './two.txt ./one.txt./three.

Shell Basics (bottom)

Shell Special Symbols1.cut command:[[email protected] ~]# cat /etc/passwd |head -2 |cut -d ":" -f 1rootbin[[email protected] ~]# cat /etc/passwd |head -2 |cut -d ":" -f 1,2root:xbin:x[[email protected] ~]# cat /etc/passwd |head -2 |cut -d ":" -f

Shell programming while & amp; until loop details (Code instance), shellwhile

Shell programming-detailed explanation of the while & until loop (Code instance), shellwhile Loop statement commands are often used to execute a command or a group of commands, so they are stopped when the conditions are not met. In shell scripts,

Total Pages: 541 1 .... 367 368 369 370 371 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.