There are three ways to invoke external scripts when running shell scripts, exec (exec script.sh), source (source script.sh), fork (./script.sh)EXEC (exec/home/script.sh):Using Exec to invoke the script is equivalent to executing a command in the current shell, without generating a new process, and the executed script inherits the environment variables of the current sh
the value of n does not change when the screen output is 21, but when the entire echo execution is complete, the value of n changes, outputting 21, 22. for this, you can easily write another test case: while [[$i-lt 10]]; Do ((i++)); echo $i |awk ' {print >> '/root/tmp/n '} '; Sleep 2; Done So why does this case see the value of N changing in real time? Don't worry, after reading this article, you will find the answer yourself. ^ _ ^ the problem with the statement (1) is that a concept under t
As 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 process, the PID, as shown in the following code: $echo $$
List of special variables
variables
meaning
$
File name of the current scr
20.16-20.17 functions in the shell
The function is to organize a piece of code into a small unit, and give the small unit a name, when the code is used to call the name of the small unit directly.
格式: function f_name() { command }函数必须要放在最前面
Script Instance 1
#!/bin/bashfunction inp(){ echo $1 $2 $3 $0 $#}inp 1 a 2
Script Instance 2
#!/bin/bashsum() { s=$[$1+$2]
Programs on the Linux server update the MySQL database every day, so remember to write a shell script, combined with crontab, to back up the database regularly. Actually very simple, the main is to use the mysqldump command with MySQL.
#!/bin/bash # Shell script to backup MYSQL database # to backup nysql databases file To/backup dir and later pick up By your # script.
Can skip few databases from bac
Here I share is learning the computer Shell scripting language method, you may not be in the software industry, but I suggest also look, because I did not say what technical details, the main share is to refine the generality of the method, which is useful for learning anything.
Of course, if you're curious enough, suggestions can also be tried in the following ways, because scientists have predicted: the future of the world is a software definition
Environment:
SSH server:192.168.100.29 server.example.comSSH client:192.168.100.30 client.example.com
Create secret key authentication through root user to implement Shell script management, distribution, deployment
First, the client side creates the secret key pair and distributes the public key to the SSH server that needs to be logged on
Note: The public key is equivalent to a lock, the private key is equivalent to a key, we here is equivalent
The recent systematic study of the shell function, the overall sense of the root of the other language function is similar, but it also has its own characteristics
One, the call function must be defined after the function, or it will be the error
Copy Code code as follows:
Fun
Fun () {echo "AAAAAA"}
Fun
The returned results are as follows:
Copy Code code as follows:
[Root@krlcgcms01 mytest]# SH fun.sh
When writing a shell script, we need to use a variety of special symbols, through these special symbols can make us write code more concise and efficient, here to the summary:
1, {} curly braces:Usage One: Wildcard extensionEg:ls My_{finger,toe}sThis command corresponds to a combination of the following commands:LS my_fingers my_toesEg:mkdir {Usera,userb,userc}-{home,bin,data}We will get Usera-home, Usera-bin, Usera-data, Userb-home, Userb-bin,userb-
SHC can be used to encrypt shell scripts, which can be converted into an executable binary file. After SHC the shell script, it generates two new files at the same time, one is the encrypted executable binary (the filename ends with. x), and the other is the original file in C (the filename ends with the. x.c).Here's how to install, SHC, and use examples:Download installation:(Website download address: http
Today on the Internet to see a web connection average time of the shell command, in their own machine tried, found that can not use, incredibly appear awk:fatal:division by zero attempted such a mistake, Mao's own changed the shell command.
Original Shell Script Example:
Copy Code code as follows:
Cat access.log|grep "Connect CBP" |awk ' begin{s
example, we all cut according to line 1000.[Email protected] test]# split-l a.txt[Email protected] test]# Wc-l *XaaXabXacThis way, each file is 1000 rows.
After the target file, you can directly empty the contents.[Email protected] ~]# > A.txt[email protected] ~]# cat A.txt
Annotation characters#: The shell entered after the # number does not come back into effect, and its role is to explain the explanation.$: variable prefix,! $ combin
1. Basic Knowledge1.1 What is Shell programming?In Unix, shell is not a simple command interpreter (typical DOS in Windows), but a fully functional programming environment. Shell is a part of the operating system, used to deal with users, and can be used to coordinate various commands [1 ]. It is very convenient to use Shell
Shell BASICS (9) functions, shell Basics
Functions allow us to divide a complex function into several modules, so that the program structure is clearer and the code reuse rate is higher. Like other programming languages, Shell also supports functions. Shell functions must be defined before use1. The Definition Format o
#一个shell的启动流程 #shell have some variables, called environment variables, which can be inherited, #比如父shell有 $UID, child shells can have, and inherit the parent shell. #正常我们声明一个变量, a=1, in the child shell, A is empty, and the variable declared by itself cannot be continued. If
1. Single quotation mark (')
# grep Susan Phonebook
Susan Goldberg 403-212-4921
Susan Topple 212-234-2343
If we're looking for Susan Goldberg and can't use the grep Susan Goldberg Phonebook command directly, grep treats Goldberg and phonebook as files to search for
# grep ' Susan Gold ' phonebook
Susan Goldberg 403-212-4921
When the shell encounters the first single quotation mark, it ignores all the special characters that are followed up to the cl
Tags: box page open down pre--download net. NetBuild Shell Script Editor under Eclipse-Install the Eclipse plugin for development shell shelled1, install "man-page Viewer" plug-in (shelled need, some machines do not need, first loaded)Installation Address: http://download.eclipse.org/technology/linuxtools/updates-nightly/2, install "shelled" plug-inDownload the shelled Zip package in http://sourceforge.net/
01. Learn the knowledge storage required for Shell programming1.VI, VIM editor commands, VIMRC settings2. Command base, more than 100 commands3. Basic, high-end network services, Nfs,rsync,inotify,lanmp,sersync,sshkey batch distribution management02.shell Scripting Concepts1. What is a shellThe shell is a command interpreter, at the outermost end of the operating
From: http://mindream.wang.blog.163.com/blog/static/2325122220084624318692/Fork (/directory/script. Sh)Fork is the most common. It uses/directory/script. Sh directly in the script to call the script. Sh script.Run a sub-shell script to execute the call. When Sub-shell is executed, parent-shell is still running.After sub-shell
(This seriesArticleOriginal by lemon (lc_mtt), reprinted please indicate the source, thank you ~)
Windows shell programming, that is, Windows shell programming. The resource manager and the entire desktop are a shell.
For more information about the basic concepts of Windows Shell, see the Windows
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.