Shell script programming under Linux 2

1. If you judge some special usageIf [-Z $a] This indicates what happens when the value of variable A is emptyif [!-e file]; Then what happens when the file doesn't exist?if (($a ,==,!=,>=,$ $ does not exist, so n is empty;[Email protected] ~]# n= '

Shell script Bulk Build configuration file

If you manage a large number of sites and servers, it is quite painful to modify the configuration file every time. So I thought of using shell scripts to generate bulk configuration files and configuration data. The following script is a shell

Small problems in Shell programming

1, the variable with = assigned value when the left cannot have spaces. For example , UserName =nihao returns userName: Command not found . Because this place username as a command to deal with. The right approach is to Username=nihao.Careful is the

Use of 2>&1 in the shell

A related knowledge 1) By default, the standard input is the keyboard, but it can also come from a file or pipe (pipe |). 2) By default, the standard output is terminal (terminal), but can also be redirected to a file, pipe, or post quotation mark

Shell Process Control-IF statement

Single-branch If condition statementIf [conditional judgment]; ThenProgramFiExample: Judging partition usage#!/bin/bash# Author:huangrui (email:[email protected]) rate=$(DF-H |grep "sda1"|awk '{print $}'|Cut-F1-D"%") if[$rate-GT the]; Then Echo

Shell whitespace issues

1. When defining variables, You cannot leave spaces on either side of the = sign.egGender=femal------------RightGender =femal-----------Wronggender= femal-----------Wrong2. Conditional test statement [the symbol is left blank on both sides .]egif

Shell Script (ii)

Shell Script (ii)#find查找文件 to find based on time, name, UID, GID, permissions, size, etc.A file or directory accessed within #-amin-10:10 minutes; a file or directory accessed +10:10 minutes ago. The time unit is minutes.#查找10分钟之前30分钟之内访问过的文件或目录Find/

Several methods of shell script de-weight

Test file cat >testjasonjasonjasonfffffPress CTR + D to save1, Sort-usort -u testfffffjason2, UniqUniq TestjasonfffffjasonThis shows that Uniq needs to be sorted before it can be re-3, sort, pipe and uniq combined use Remove duplicates

Shell parameter passing

$# 是传给脚本的参数个数$0是脚本本身的名字$1 是传递给该shell脚本的第一个参数$2是传递给该shell脚本的第二个参数[email protected] 是传给脚本的所有参数的列表$* 是以一个单字符串显示所有向脚本传递的参数,与位置变量不同,参数可超过9个$$ 是脚本运行的当前进程ID号$? 是显示最后命令的退出状态,0表示没有错误,其他表示有错误 Difference:@* Same point: All parameters are

Shell Review notes----commands and Parameters

The basic job of the shell is to execute commands.The shell executes each command you type.$CD work;ls-l whizprog.cFirst: The format is simple, separating the various components of the command line with a blank Space key or TAB key.Second, the

The Nginx service program written by Shell

the Nginx service program written by Shell can be added to the/etc/init.d/directory first. chkconfig--add nginxd chkconfig nginxd on Service Nginxd Start Service Nginxd Stop service Nginxd "Restart | Reload | Test | Status " #!/bin/bash#chkconfig:-

Unbuntu Run a shell script problem

Today learn bird's private dishes, according to the book hit a few shell script, but the total errorThe first is to use [] to determine the condition, = = does not work properlyThe second is to declare variables in the script to use declare, always

Linux shell command

ls command file, directory Operation commandLS Displays the current directory by defaultLs-a Show All Files hidden filesLs-l Display file propertiesLS-LH Display File sizeLs-lt display files sorted by modified time cd Command Change

Basic shell command

Setting environment variables#Set java_home=/root/deploy_ws/jre1.8.0#PATH = "$PATH:/home/user/bin"Calculate the length of a string#var = "12345"#echo ${#var}Shell currently in use#echo $SHELLQuerying the role of the current user#echo $UID//If root

Shell Review notes----Introductory knowledge

A Brief History of Unix UNIX was originally developed by the Computer Science Research Center of Bell Telephone Laborataries, the first version of which was born in 1970 – shortly after Bell Labs withdrew from the Multics project. Among the

First shell script

Http://c.biancheng.net/cpp/view/6998.htmlOpen a text editor, create a new file, the extension sh (sh for Shell), the extension does not affect the execution of the script, see the name is good, if you write a shell script in PHP, the extension is

Shell common Text Processing commands

grepIf you want to use a regular expression, add the parameter Grep-e "[a-z]+" #使用正则表达式or egrep "[a-z]+"-a-b output matches a few lines before or after the line-C to display a few lines at the same time-e matches multiple styles, such as GREP-E "cat"

--shell Programming for Linux Programming (chapter II)

Chapter II Shell ProgrammingThe following sections are described in this chapter:What is a shell?Basic ideasSubtle syntax: variables, conditional judgments, and program controlCommand ListFunctionExecution of commands and commandsHere

Shell Script Basic Commands

How shell scripts run$sh script.sh$sh/home/path/script.sh$chmod a+x script.sh; $./script.shEcho's three ways to use echo Hello World Cannot contain some special keywords, such as semicolons;echo "Hello word" Cannot contain some special characters,

Shell basics 3: shell Basics

Shell basics 3: shell Basics Cut is a selection command: It is to analyze a piece of data and retrieve what we want. In general, the selection information is usually analyzed for "rows", not the entire information analysis. (1) The syntax format is:

Total Pages: 541 1 .... 371 372 373 374 375 .... 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.