One, single branch if statement
Format: if judge condition; then
Statement1
statement2 ...
Fi
Two, two-branched if statement
Format: if judgment condition; Then
Statement1
statement2 ...
else
statementn
...
Fi
Use a previously used script to illustrate this structure.
Three, multiple branch if statement
Format: If Judge condition 1;then
Statement1 ...
Elif judgment Condition 2; Then
statement2 ...
Elif judgment Condition 3; Then
statement3 ...
else
state
Each line that the Shell reads from standard input or script is called a pipe (pipeline); it contains one or more commands (commands) that are separated by one or more pipe characters (|).
In fact, there are many special symbols that can be used to separate individual commands: semicolons (;), Pipes (|), , Logical AND (), and Logical OR (| | )。 For each of the read pipes, the shell splits the command back,
Because often use the shell script, so often will write some, but I have never systematically learned the shell script, encountered problems, go to the manual, or Google, to a certain extent to find their foundation is really bad. The following is a little useful script to learn about the shell in the system.
1, backup the file below the directory
Copy C
First, the Shell function
All scripts so far in this tutorial have been executed from beginning to end. This is good, but you may have noticed that some of the script segments are duplicated.
The shell allows a set of command sets or statements to be formed into a usable block called a shell function.
Functions in the shel
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 variablesLocal variablesEnvironment variablesPosition variableSpecial variables (built-in)
Second, local variables:
Varname=value: Scopes are available for the entire bash process;
Variable Naming conventions:
1. Can only contain letters, numbers and un
The key to using command-line arguments is that the shell script needs to interact with the person who is running the script.The bash shell provides command-line arguments to add data values after the command, command line options to modify the command behavior of single character values, and direct read keyboard input.
1, command line parametersThe most basic way to pass data to a
1. "" "" "The Difference," "The variables will be resolved" "All of them as strings" "to execute system commands
2. The custom variable defaults to a local variable, and the environment variable is a global variable.
3.export can set one or more variables as global variables
4. To use a variable in a child shell in the parent shell, you must set the variable to global with export
5. Commonly used enviro
What is Classic shell? Classic Shell is a Windows Start Menu tool that provides three start menu styles such as XP classic style, Vista double column classic style, Win7 two-bar evolution style, and can also replace your favorite "Start" button icon, is a recognized Start menu customization Tool.
In layman's words, the classic shell is a Windows Start menu t
Tags: Shell special variablesShellSpecial variables: Shell $, $#, $*, [email protected], $?, $$ and command line argumentsAs already mentioned, variable names can only contain numbers, letters, and underscores, because some variables that contain other characters have special meanings, and such variables are called special variables.For example, $ represents the ID of the current
Shell script entry, shell script
There are two ways to use Shell script:
① Interactive: each time a user inputs a command, the Shell immediately executes the command;
② Batch: You can compile a complete Shell script to execute many commands in the script at one time.
View t
1, look at the machine installed which shell?
There are two ways to view it.
First type:
[Rocrocket@wupengchong ~]$ Chsh-l/bin/sh/bin/bash/sbin/nologin/bin/zsh
The second type:
[Rocrocket@wupengchong ~]$ Cat/etc/shells/bin/sh/bin/bash/sbin/nologin/bin/zsh
In fact, Chsh-l also to view this file.
2, see which Shell is currently in use?
[Rocrocket@wupengchong ~]$ Echo $
There are several ways to execute a shell script
1, relative path mode, need to first CD to script path
Copy Code code as follows:
[Root@banking tmp]# Cd/tmp
[Root@banking tmp]#./ceshi.sh
Script execution succeeded
2. Absolute path mode
Copy Code code as follows:
[Root@banking tmp]#/tmp/ceshi.sh
Script execution succeeded
3. Bash Command call
Copy Code code as follows:
[Root@banking
Question: I want to know the process ID of the script shell in the run. How do I get the PID in the shell script?
When I execute the shell script, it starts a process called a child shell. As a child of the main shell, the child shell
As mentioned earlier, we can use php to develop Shell programs. Some may ask: Isn't php used for web pages ?. Yes, php can be used for dynamic web pages, and php was originally developed for dynamic web pages, but php can be used for any program in theory,
1. basic knowledge1.1 What is Shell programming?
In Unix, shell is not a simple command interpreter (typical
Write shell program
Execute shell program
Shell programs have many features similar to C and other programming languages, but they are not as complex as programming languages. A shell program is a series of Linux commands and utilities stored in a file. During execution, each command is interpreted and executed one b
This article focuses on the core foundations of shell variables.1. What are the variables?What is a variable? Many people may not understand, simply put, a variable is a fixed string (or possibly a combination of characters, numbers, etc.) instead of more, more complex content, the content may also contain variables, paths, strings and other content.Variables are assigned by: Write the name of the variable, followed by the "=" character, and finally t
Tags: shell old boy script1, SH and./The Difference[email protected] ~]# cat test.shEcho I am thzzc1994[Email protected] ~]# sh test.shI am thzzc1994[Email protected] ~]# bash test.shI am thzzc1994[Email protected] ~]#./test.sh-bash:./test.sh: Insufficient permissionsWant to let./can execute, need to be in user bit plus permission x (executable exec meaning),Executing chmod u+x test.sh in my environment is equivalent to chmod 744 test.sh:[email protec
MongoDB BSON provides support for additional data types than JSON. Drivers provide native support for these data types in host languages and the MONGO Shell also provides several h Elper classes to support the use of these data types in the MONGO JavaScript Shell. See the Extended JSON Reference for additional information.TypesdateThe MONGO Shell provides various
2015-05-08 00:15 3896 people read review (US) Collection report This article has been included in:Classification:Advanced Software Development (419) Author of similar articlesX
unix/linux Miscellaneous (118) Author of similar articlesX
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.In this era, we write some books, but also just to make some money, basically is a list of some knowledge points, is basically written to the
Linux Shell Scripting Basics Here we first talk about the shell's grammatical basis, beginning, annotation, variables and environment variables, to do a basic introduction, although not involved in specific things, but lay a good foundation for later learning easy premise.1. Linux Scripting BasicsBasic Introduction to 1.1 grammar1.1.1 StartThe program must start with the following line (must be on the first line of the file):#!/bin/shThe symbolic #! i
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.