After logging into the system, we are the Shell interaction environment, use it every day to work, have a customized environment can make us more efficient.1.PS1 variableIt is found that there is a string of characters on the left side of the cursor
Optimized content includes kernel (commented out at the end of the article, see Personal needs) SSH time sync yum source#!/bin/bash#update Time 20180824#version 1.1.0Echo-e "\033[31m------------------------------Author name is Hefangyaonie-----------
1, disk use warning and send mail#!usr/bin/bash#df-th|grep '/$ ' This is the record that gets the memory used#后面两句是获取内存的使用率disk= ' df-th|grep '/$ ' |awk ' {print $ (NF-1)} ' |awk-f '% ' ' {print '} 'Mail_user=natashaIf [$disk-ge];thenecho "' Date
A shell script is a function that uses the Shell's command interpretation to parse a plain-text file and then perform these functions, or it can be said that a shell script is a collection of commands.The shell can be used directly above the
Shell Scripting Fundamentals for Programming Basics程序:指令+数据 程序: 算法+数据结构数据:是程序的核心数据结构:数据在计算机中的类型和组织方式算法: 处理数据的方式程序编程风格:过程式 :以指令为中心,数据服务于指令对象式 : 以数据为中心,指定服务于数据shell程序: 提供了编程能力,解释执行How the program is executed计算机:运行二进制指令编程语言:人与计算机之间交互的语言低级编程语言:机器:二进制的0和1
测试操作符
Common Test Operators
English name
Description
-F file
file
files exist and are normal files True, that is, test expressions are set
-d file
Direct Ory
Shell annotationsUse # as the comment symbolThere are no multiple lines of comments in the shell, only one line plus a # numberString manipulation1. Stitching strings 2. Get the string lengthString= "KHJF"echo ${#string}3. Extracting
Step 1: Master several if statement branches
The following is the most complete if format. You can delete it as needed in actual use.
If condition; then
// Action
Elif conditon: then
// Action
... Several intermediate Elif
Else
//
''Causes sed Command Parsing to fail. The experiment is as follows:
Try to replace a single backslash with two backlash, that is\ Replace \\
$ Cat t1.sh#! /Bin/shA = 'echo 1 | SED's/\/g''Echo $
$./T1.shSed:-e expression #1, character 8:
2.6.6 Command Execution
1 $ (command): capture the execution result of a command and use it in the shell script programEcho the date is $ (date) // The result is the output of the command, which is a string output.Set $ (date)Echo the month is $2 //
1. view the current system memory usage (free ):
The free command has the following common options:
-B displays data in bytes.
-K displays data in kilobytes (Kb) (default value ).
-M displays data in MB.
-S delay this option will enable
To determine whether the variables in a script are empty, I wrote a shell script like this:
#! /Bin/sh
# Filename: Test. Sh
Para1 =
If [! -N $ para1]; then
Echo "is null"
Else
Echo "not null"
Fi
Then run the Script: test. sh uses
The current Code only contains the part used to create a file image and generate a file system.
#! /Bin/sh # log = ". /version_make.log "root_path = ". /update_file/network_update "log = ". /update_file/version_make.log "ver_f = ".
Some questions on SuSE may need another reference: http://blog.chinaunix.net/u2/64804/showart.php? Id = 2026903
Related versions: Red Hat Enterprise Linux
Symptom:
If you set the value in the file/etc/security/limits. conf. However, if you log
Http://hi.baidu.com/zxvb3000/blog/item/9ecd2b022d15490b4bfb5199.html
1. Test commandThe test command is used to check whether a condition is true. It can be used to test values, characters, and files,The test characters and corresponding functions
The shell script was called for half an afternoon .. Shell is really a Nb tool .. Thanks for a space. If you do not enter one space, the space can be adjusted to death ..
1. There are some very strange errors. The error location during execution is
Today, we can see that awk in a shell script processes strings, and there is a gsub ("\\. [0-9] + $ "," ", $2), and the $2 format is 00:12:13. 333, this gsub wants to put. 333. The regular expression in the regular expression cannot be matched. it's
Sometimes a task runs for a long time and needs to be run in the background. Otherwise, the task will be terminated after the console is launched. This article describes how to run the task in the background.
For example, for a shell script,
The process and runtime classes are used. The returned values are obtained using the getinputstream () method of the Process class.
package ark;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import
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