The Linux Shell script has been divided into several parts, and the content of the control process is now finished. This is the last part about here document. The example here is a little complicated, we will analyze this complex Linux Shell script.
Mysql1 # Cat mysqlbackup. Sh#! /Usr/local/bin/fish # The backup policy is daily full backup # Setting backup path variables Set backupdir/usr/DB/backup # Generate a backup directory Mkdir-p $ backupdir # Delete a backup that has been backed up for
Linux Shell script basic learning Lecture 3: When we introduced shell commands and Process Control in the previous section, we could not talk about process control due to space limitations, today, we will only introduce the first three parts of if
Linux Shell script basics if you only look at the previous theoretical section, although there are some examples, but it is not systematic enough, here we will show you a specific example of Linux Shell script programming, to help you learn and
In the case of a lot of service logs or a lot of scattered files that need to be sorted together in batches, the shell script can be quickly used to solve the problem:
Date = $ (date + % Y _ % m _ % d-% H % m % s); find *-type F | while read file;
Conditional statement if-then Structure
If [condition]ThenCommandsFi
Note: To put then and if in the same row, you need to write the following:If [condition]; thenIn shell.
In addition,There must be a space between [] and condition !!!For more
Variable configuration rules
The variable and the variable content are linked with an equal sign "=", as shown below:"Myname = vbird 』
The equal sign cannot be directly followed by a space character, as shown below:"Myname = vbird" or "myname
-B. returns true if the file exists and is a block file.-C: returns true if the file exists and is a character file.-D. If pathname exists and is a directory, true is returned.-E: returns true if the file or directory specified by pathname exists.-F
I have been busy recently, and occasionally spend some time reading books to supplement my energy. Recently I am studying programming languages-I am very touched by the road to practice. What I 've learned by mistake is a more system, the complete
During the bug quality analysis, the word segmentation should be sorted and de-duplicated, so we thought of sort and uniq.
It is very convenient to call shell through python.
#-*-Coding: UTF-8 -*-Import OSImport sysDef cws_statistics (flag, afile,
If you have a small requirement at work, you need to rename a series of files.
The original format is string_1.obj. Now you want to change the number in the file name to a fixed length. If the number is less than the number of digits, it is changed
All Unix users should understand how to use the Korn shell script. By writing shell scripts, You can automate many tasks and save a lot of time. It seems daunting at first glance, but you can use it skillfully as long as you follow the correct
How to extract the line Content Code specified by the file:
If you only want to view the first five lines of the file, you can use the head command,For example: Head-5/etc/passwd
If you want to view the last 10 lines of the file, you can use the
LinuxIf command
WhateverProgrammingLanguage is inseparable from conditional judgment. Shell is no exception.If list thenDo something hereElif list thenDo another thing hereElseDo something else hereFi Ex1:#! /Bin/shSystem = 'uname-S' #
In Windows, there are some files that can be decompressed by yourself, that is, the so-called self-decompressed files. You don't need to know which compression technology is used to compress the file, you can simply decompress the file by running
Conditional expression:
1. File expression
# If the file exists if [-f file] # if the directory exists if [-d dir] # if the file exists and is not empty if [-s file] # if the file exists and is readable if [-r file] # if the file exists, you can
How to Learn shell commands in Linux
I learned some of the scattered linux commands today. The following is a summary:
First of all, when you don't know how to execute commands, of course we need man. Let this man save everyone! Haha!
Common network
Shell:
#! /Bin/bash #=============================================== ====================================## this example show you how to get data from pipe #====== ========================================================== =============== while
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