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
Today to see the Unix shell example fine solution on the Youdao awk on the topic after doing it to share with you
Pre-processing documents:
Mike Harrington: (510) 548-1278:250:100:175Christian Dobbins: (408) 538-2358:155:90:201Susan Dalsass: (206)
Objectiveor do you write an automated packaging script today that takes you to get the last file name from the path name. Here is a record of the implementation process. Of course, in the end I will also give the official practice. (PS: Very awkward,
First script file
Copy Code code as follows:
#!/bin/bash
echo "This are my I-A-bash code!"
Exit 0
redirect Symbols and mathematical calculations
Copy Code code as follows:
#!/bin/bash
Echo-n "The time and
#查找当前目录中是否存在指定目录, if it does not exist, it is created
Copy Code code as follows:
function mkdir_1
{
if test! -D $
Then
mkdir $
Fi
}
#指定文件中的 "prefix =. *" string replaced with "prefix=/home/gnome-unicore-install2/usr/
To compare two strings for equality:
If ["$test" x = "Test" x]; Then
Here are a few key points:
1 using a single equal sign
2 Notice that there is a space on each side of the equal sign: This is what the Unix shell requires
3 Notice the last X of "$
First of all, let's look at the problem description, the following figure is my run-time error screenshot:
Solving method
Analyze the reason, maybe because I have a problem with my platform migration, we have permission to convert.
1 conversion
Function:1. Only in the backup machine, the remote server only need to allow the backup machine with root through the key login;2. Configure which servers to back up on the backup machine, add or subtract the array in need_backup_servers;3.
This email alert script is everywhere, a lot of use of sendmail, Postfix, feel a bit overqualified, and some use Perl net::smtp and AUTHEN::SASL module, but I use Perl is not good, The old send out some baffling mails (for example if (a>1) {print (a)
Arithmetic operations are essential in any programming language, and the shell is no exception.
First, use Let, (()) and [] for arithmetic operations
You can use the normal variable assignment method to define a numeric value, which is that it
Randomly generated 10 8-bit password shell scripts1. First Capital Letter2. Middle six-digit alphanumeric random mixing3. Eighth place [0-9]
#!/bin.bash for
i in {1..10}
do
a= ' head-c 500/dev/urandom | tr-dc a-za-z | tr [A-z] [a-z]|head-c 1
The script that prints the Java thread occupancy stack is invoked if the CPU occupancy rate continues to reach more than 80, see https://github.com/oldratlee/useful-shells/blob/master/ Show-busy-java-threads.sh, see his GitHub wiki! in concrete
One, logical operators
Logical Volume Label
Express meaning
1.
About the files and directories of the detection of logical labels!
-F
Common! Detect the existence of "archives" eg:if [-f filename]
1, the shell variable statement judgment
An expression
meaning
${var}
Variable var with the same value as $var
${var-default}
If Var is not declared, then use $default as
Sometimes we need to delete the empty folder recursively, search the internet for a while, did not find a better shell script, so we wrote a
Script
Copy Code code as follows:
#!/bin/bash
# Author: Ten years later, Lou's brother
#
Nodejs is really very hot, before the past, but never seriously recorded anything. Build its development environment under Ubuntu Try a quick, easy way to get the system to automatically help you install what you need, and we'll generate a shell
The reason for bad interpreter:no such file or directory is the file format problem. This file is written under Windows. Line-wrapping is not the same as UNIX, but under vim if it is not set it is completely invisible.Problem Analysis:1, will be
I am not studying things under Linux, so here is only a description of the use of shell script, I am in the process of using the problem recorded, but also write down some of the rules of the shell script syntax, easy to view later. Let's take a
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.