Shell Script Introduction
Shell is a scripting language
You can use logical judgments, loops, and other syntax
Functions can be custom-defined
The shell is a collection of system commands
Shell scripts enable automated operations, which can greatly i
assignments in the program do not change the values of other processes or variables of the same name in the original Shell, and do not affect their operation.A more granular document even mentions that a variable enclosed in quotation marks will not be interpreted by BASH as a variable, such as ' $STR ', but as a purely string. And the more standard way to refer to a variable is ${str}, $STR is just a simp
Learn the first script from the shell, thanks to cloud Li Qiangqiang Teacher's shell programming tutorial
To create a shell script file:Touch menu.shTouch index.shTouch welcome.sh
To give the script file permission to execute:chmod a+x menu.sh index.sh welcome.sh
menu.sh
#!/bin/
scripts written in Other languages include shell scripts written by PHP:Sometimes we may need to include shell scripts written by PHP in shell scripts written in other languages. Actually very simple, here is a simple example:#!/bin/bashEcho this was the Bash section of the code./usr/local/bin/php-q print ("This was t
Often, when people refer to the "Shell scripting language", they are bash,ksh,sh or other similar Linux/unix scripting languages emerging in their minds. Scripting languages are another way to communicate with a computer. Users can move the mouse and click on a variety of ob
Learn the first script from the shell, thanks to cloud Li Qiangqiang Teacher's shell programming tutorial
To create a shell script file:Touch menu.shTouch index.shTouch welcome.sh
To give the script file permission to execute:chmod a+x menu.sh index.sh welcome.sh
menu.sh
#!/bin/
First part: Linux command line"Linux command line and Shell Scripting Encyclopedia" chapter I: the first knowledge of Linux shell"Linux command line and Shell Scripting Encyclopedia" chapter II: Into the shell"Linux command line a
1. Linux Scripting Basics
1.1 Basic Introduction to grammar
1.1.1 Start
The program must start with the following line (must be on the first line of the file):
#!/bin/sh
The symbolic #! is used to tell the system that the parameters behind it are the programs used to execute the file. In this example we use/BIN/SH to execute the program.
When you edit a good script, you must also make it executable if you want to execute the script.
To make the
1#!/bin/Bash2 ############################################3# @content Chapter8,9of Linux Command line and Shell Scripting Bible4 # @reader Gavin5# @date the/ A/ -6 ############################################7CHAPTER88 9+user varriable make the shell A-computer programTen 1when assigning a value to a user-defined variable, no spaces can appear One 2.
bash_rematch[] array #re1.sh#!/bin/bash# manage to know your nameread-p "Please input your fullname:" Nameif [[$NAME =~ (. *) [[: Space:]] (. *)]];thenecho "Your last name ${bash_rematch[2]}" echo "Your name is ${bash_rematch[1]}" echo "Full name ${bash_rematch[0 ]} "fi execution results [[email protected] shell]#./re1.sh Please input your Fullname:liancao Liu your surname Liu you call liancao full name Li
This article collects a bunch of shell scripting tricks, I said, I write a blog mainly to make some learning notes to facilitate their own review, so I will make such an article, there is nothing incomprehensible. About the origin of these techniques, eh, I also forget, may come from Theunixschool, Commandlinefu, cool and igigo.net, of course, there are some of my own experience, tube him, into my brain is
Do monitoring and backup up to1. What is a shell script?It's a scripting language, not a programming language.You can use some logical judgments, loops, and other syntaxYou can customize the sub-functionis a collection of system commandsShell scripts enable automated operations, greatly increasing our productivity first shell script: mkdir
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 entir
Microsoft PowerShell, which provides you with full functionality to operate MS Windows.question four: What is the difference between a scripting language and a normal programming language? The programming language "write-compile-link-run", the scripting language is "interpretation-execution" rather than compiling, the script language of the program code even if the final executable, through the correspondi
Like other shells in Linux, Bourne Again shell is not only an excellent command-line SHell, but also a scripting language. Shell scripting allows you to take full advantage of shell functions and automate multiple tasks that requi
2 3
Do
For var2 in 0 5
Do
if [ $var 1 -eq 2-a $var 2 -eq 0 ] /c0>
Then
break 2
Else
Echo "$var 1 $var 2"
fi
Done
Done
As above, break 2 means to jump out of the outer loop directly. Operation Result:1 01 5Continue commandThe continue command is similar to the break command, with only a little difference, and it does not jump out of all loops and just jumps out of the current loop.To modify the above example:
#!/bin/bash
to customize their command aliases and private script functions3. non-interactive shellThis is the shell used by the system to execute shell scripts.There is no command line prompt.Bash shell provides bash_env environment variables. When a non-interactive shell is started, bash_env is checked to see the startup file t
, many linux releases come with python. It is okay to replace shell with python to write scripts. @ Yu Tiansheng said that "inertia" is very reasonable, but there are many people around me who have switched to zsh (including me) on others' recommendations after using bash for many years ), the switchover is completed in just a few days. After learning that the vi in the Debian system is just the alias of vi
Use PHP as the Shell scripting language, read the use of PHP as the Shell scripting language, -- English original: DarrellBrogdon, published in http://www.phpbuilder.com/columns/darrell20000319.php3) many may have thought about using PHP to write some program such as timed sending, but it is impossible to execute
Darre
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.