Linux Server Shell Programming learning notes

The introduction to shell scripting is what this article is about, and we can use any type of text editor, such as Gedit, Kedit, Emacs, VI, to write the shell script, which must begin with the following line (must be placed on the first line of the

Linux shell Implementation Transform input date format _linux Shell

For the user to enter the validity of the date test is a very important issue, this example is simple to get the user entered the date, and converted to the appropriate format, but not perfect, why please read the text. #!/bin/sh #

Linux server hardware running status and fault message alert monitoring script sharing _linux Shell

Monitor hardware Health Shell monitor Cpu,memory,load average, log to log, when load pressure, email notify admin.Principle:1. Get the value of the Cpu,memory,load average2. Determine whether the value exceeds the scope of the customization, for

Summary of mathematical calculations in shell _linux Shell

sin

1. Examples of error methods A Var=1+1 Echo $var The result of the output is 1+1, tragedy, hehe b Var=1 var= $var +1 Echo $var The output result is 1+1, still tragic, hehe 2. The correct method 1) using Let Var=1 Let "Var+=1" Echo $var The output

Linux and Windows automatic FTP script (shell bat) _linux shell

First, look at the Linux under: Copy Code code as follows: #! /bin/bash cd/ftp/ Currentdate= ' Date +%y%m%d ' Yesterday= ' date-d yesterday +%y%m%d ' Threedayago= ' date-d ' 3 days ago ' +%y%m%d ' #echo $TWODAYAGO Ftp-n-I 34.97.34.3

Shell script for detecting network segment IP usage _linux shell

Copy Code code as follows: #!/bin/bash #main--- network=192.168.1 Ping_count=3 Ip=1 : >ip_use : >ip_idle : >ping_action echo "' Date" +%y%m%d%h:%m:%s "'-----> Script starts executing ..." While [$IP-LT 255] Todo host= $network. $IP

8 ways to count the number of rows in a shell script statistic file _linux Shell

Get the number of rows in a single file File: test1.sh Number of rows: 20 Method One Copy Code code as follows: awk ' {print NR} ' test1.sh|tail-n1 As shown in the figure: Method Two Copy Code code as follows:

Code to read and output data using shell commands _linux shell

The shell script reads data in several ways:1. keyboard input, default2. read from the file3. Pass through Pipeline command Functions of Echo:\c: No Line change\f: Paper Feed\ t: the jump Grid\ n: Wrapping Line\ represents escape, for example:

Shell code to prevent ARP attacks _linux shell

Copy Code code as follows: #!/bin/bash Declare gw= ' Route-n | Grep-e ' ^0.0.0.0 ' Declare gwname= ' echo $GW | Grep-oe ' \w*$ ' Declare gwip= ' echo $GW | Grep-oe ' [0-9]\{2,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\} '

Shell Programming Basics Summary _linux Shell

1, File type introductionLinux systems mainly include the following seven types of files: D directory-normal file L Symbolic link s socket file B block device file c character device file p named pipe file 2, Regular expressionRegular expressions

Several common Linux operating system monitoring script code _linux Shell

This paper introduces several common Linux monitoring scripts, which can realize the automatic monitoring and alarming of host network card traffic, system condition, host disk space, CPU and memory usage. According to their own needs to write a

A detailed explanation of the variable types in the Linux bash Shell _linux Shell

In the Linux system for day-to-day operations or scripting, variables are more familiar with, but what are the types of variables, what is the difference in the specific usage? This paper is to share with you: One, bash variable type: Local

Linux Shell Script Tutorial Series (v): Mathematical operations _linux Shell

Arithmetic operations are essential in any programming language, and the shell is no exception. First, use Let, (()) and [] for arithmetic operations You can use the normal variable assignment method to define a numeric value, which is that it

Linux Shell Script Series Tutorial (iv): Adding environment variables using functions _linux shell

First, Introduction Environment variables are typically used to store path lists that are used to search for executables, library files, and so on. For example: $PATH, $LD _library_path, they usually look like this: Copy Code code as follows:

Shell script sharing for server information (Ubuntu, CentOS test pass) _linux Shell

This script has been tested on the Ubuntu and CentOS versions, and the script is as follows: Copy Code code as follows: #!/bin/bash Line= ' =========== ' #linux发行版名称if [[-f/usr/bin/lsb_release]]; Thenos=$ (/usr/bin/lsb_release-a

Considerations for Linux shell script programming _linux Shell

ssh

First, the common skills Copy Code code as follows: SSH User@server Bash #ssh到远程服务器执行一个脚本, this command avoids uploading scripts to a remote server SSH User@host Cat/path/to/remotefile | Diff/path/to/localfile-

Linux shell logical operators, logical expressions detailed introduction _linux shell

One, logical operators Logical Volume Label Express meaning 1. About the files and directories of the detection of logical labels! -F Common! Detect the existence of "archives" eg:if [-f filename]

Shell implementation read INI format config file method _linux Shell

INI file format is generally composed of sections, keys, values of three parts Format: [Section I.]First key = valueSecond key = second value[Section II]First key = Val1,val2,val3Example: Copy Code code as follows: [COM] Kinggoo =

Methods for printing color fonts and color backgrounds using echo in the shell _linux shell

It's fun for the terminal print in the shell!First know that the end of the shell print has echo printf is commonly used is echo slightly; Note: Font Color reset = 0, black = 30, red = 31, green = 32, ***=33, blue = 34, magenta =35, cyan = 36,

Nginx log cutting and deletion of the shell script of historical logs 7 days ago

Example 1,Cut nginx logs by date and automatically delete logs generated seven days ago (logs have been synchronized to dedicated log storage servers, so you can safely delete historical logs .)#! /Bin/bash# InitializationLOGS_PATH =/data/nginx/logs/

Total Pages: 541 1 .... 154 155 156 157 158 .... 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.