First, write some basic syntax:
1. String judgment
Str1 = str2
True when two strings have the same content and lengthStr1! = Str2True when str1 and str2 are different-N str1: true when the length of a string is greater than 0 (the string is not
The example above the Linux Shell script illustrates the conversion of decimal and binary, and ends the learning of this Part with an instance related to file loops. I believe that the basic learning of Linux shell scripts should be able to master
The Linux Shell script has been divided into several parts, and the content of the control process is now finished. This is the last part about here document. The example here is a little complicated, we will analyze this complex Linux Shell script.
Linux ShellVariable auto-increment is often used when writing a loop. Now let's summarize the auto-increment method of integer variables.As I know, bash currently has five methods:1. I = 'expr $ I + 1 ';2. Let I + = 1;3. (I ++ ));4. I = $ [$ I + 1];5
Sender Shading
From Pixar's paper
Sender Shading
This slice of hair shell is based on FMM (Fast Marching Method) to obain A Level Set function in order to get a "imaginary" curve normal for hair
I would like to remind you that this client sends a UDP heartbeat packet to the server through port 6060. The package information is as follows:
17:19:35. 734433 IP 192.168.1.7.32773> 61.152.96.119.6060: UDP, length 2017:19:35. 784568 IP 61.152.96.
recently, I have been engaged in Unix shell and read a lot of books and materials in this process, therefore, we will record some of the details to be noted for the purpose of memo and reminder. The shell here refers to the Bourne shell. I have
1. Echo "AA"> test.txt and echo "BB"> test.txt //> clear the original file and write the content to the file.> put the content at the end of the file.2. chmod go + w-r/home/zhangy // Add write permissions to group users and other users3, tar-tzvf
In the Linux Shell environment, input and output redirection is supported, expressed by symbols . 0, 1, and 2 indicate the standard input, standard output, and standard error information output, which can be used to specify the standard input or
1. file security and permissions
1 file typeD directoryL Symbolic LinkS socket FileBlock B Device FilesC character Device FileP name MPs queue File-Common files
2. For the file owner, if only the read permission bit is set, the file can still
2. Control Flow Structure
Exit status
While, for, and until loops Loops
If then else statement
Actions in the script
Menu
1. ExitAn exit status is returned when any command is running. To observe the exit status, run the following command:$
In the case of a lot of service logs or a lot of scattered files that need to be sorted together in batches, the shell script can be quickly used to solve the problem:
Date = $ (date + % Y _ % m _ % d-% H % m % s); find *-type F | while read file;
The script is:Nohup/mnt/nand3/h2000g>/dev/null 2> & 1 &For & 1, it should be file descriptor 1, while 1 generally represents stdout_fileno. In fact, this operation is a dup2 (2) Call. it outputs the standard output to all_result, and then copies the
A few days ago, I sent a redirection and pipeline-related usage method. Here are some interesting examples. Implement TCP/UDP-based software communication through redirection.
The Linux device contains a special file:
/Dev/[TCP |
I. Variable assignment
#! /Bin/bashA = "Hello World"#= No space is allowed on both sides!Echo"A is$"UnsetAEcho"This is $ {A} Nd"#It is best to use {} to expand the variable to avoid confusion.
Declare-I num1 = 10Declare-I num2 = 20Declare-I num3
First line #! Bin/sh
End with exit 0
Judgment:
I = "morning"
If test "& I"-EQ "morning"
Then ECHO "& I"
Elif test "& I"-EQ "Afternoon"
Then ECHO "$ I"
Else
Echo "night"
Fi
Echo "Please input yes or no"
Read I
Case ($
WCCommandTo count the number of bytes, number of words, and number of rows in a specified file, and display the statistical results.
Syntax: WC [Option] file...
Note: This command counts the number of bytes, number of words, and number of lines
Eclipse on Mac often needs to manually close the Java Process, which is a little troublesome. Write a simple shell in. bash_profile and use the port number to close the process.Lsof-Ti: 9001.Then $ source. bash_profile can use the killps command.
DeclareOrTypesetBuilt-in commands (they are identical) can be used to restrict attributes of variables. This is a method that is not strictly defined in some programming languages. CommandDeclareIt is only available after bash version 2.
Excerpted from: ABS_Guide translator Yang chunmin Huang Yi
When will Shell scripts not be used?
Resource-intensive tasks, especially when efficiency needs to be considered (such as sorting and hash)
Mathematical operations that require processing
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.