Backs up all modified files in the current directory within the last 24 hours in a "tarball" (Files that have been processed by tar and gzip).The program code is as follows:#!/bin/bashBACKUPFILE=backup-$(date +%y-%m-%d)#
1. What is a shell?Open the system, enter ZS, press the Tab key, the command Zsoelim appears,Description No zsh command, this time can be installed, first enter the command yum list |grep zsh, enter, search,You can see that there are zsh commands,
1. The way bash checks the environment variable file depends on how the system runs the shell, typically there are 3 ways the system runs the shell:1 shell that runs by default after the system user logs on 2 ) Non-login interactive run shell 3)
Using Nginx log file to count all IP and PV, list the top 10 IP, take confluence Knowledge base system as an example:Nginx log file is/var/log/nginx/access.log# wc -l /var/log/nginx/access.log 95146 /var/log/nginx/access.logShell script:# vim
Exercise 1: Counting Memory usageRequirements: Write a script that calculates the amount of memory that is consumed by all processes in the Linux system. (Hint: use PS or top command)Reference Answer:#!/bin/bash# date:2018 February 6 # using top to
File expression-e filename true if filename exists-d filename If filename is a directory, true-F filename True if filename is a regular file-L filename True if filename is a symbolic link-r filename If filename is readable, true-W filename if
One, pipe and operation control1, the pipe symbol "|", is to put the results of the previous command run to the following command.LS |wc-l; LS |grep test2, how we are editing a file, want to pause this operation and exit can enter Ctrl Z Pause task3.
1. For Loop statement:Two common ways to use for: notation (1): for inch 1 2 3 4 5 (PS in $ (seq15 in {1). 5 }) do echo"$val " DoneNotation (2): for ((i=0;i; i++)) ( PS: Must Be for (()) ) { "val=i%2"
Using shell functions to develop the Rsync service startup script, previously unprofessional#!/bin/bash#chkconfig: 2345 20 80 #这两行加入kconfig #description: saves and restores system entropy poolsource /etc/init.d/functions
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
1, for: Read different variable values, execute the same set of commands one by one, until the value is complete exit, variable values are separated by a spaceSyntax: For variable value in value listDoCommandDone2, while: Repeated testing a
The issue cannot be removed after using HBase shell entry in Xshell:In the HBase shell, the wrong input instructions can not be deleted using backspace and delete, the use of the people know that this is a lot of pits, there is much distress!OK,
Power ShellNote: The following content is written on a non-Windows platform, there may be spelling errors, if any, please correct me, I will amend as soon as possible. It can be implemented using the PowerShell configuration file (\ Profile). \)The
Shell script sum (Code instance), shell script sum instance
The principle is as follows:
1) define two variables I, sum, both initialized to 0 2) define a loop body, calculate the sum. 3) Use let $ sum = $ sum + $ I to replace the value. 3) sum of
Shell scripts automatically log on to the server and install JDK (Code tutorial), shelljdk1. Write the installation script
Install. sh
! /Bin/bashURL = "https: // ***/jdk-8u161-linux-x64.tar.gz "yum install-y wgetwget $ URLtar-zxvf jdk-8u161-linux-
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