By failing time after time, I finally master the tricks of writing Linux Shell, the most classical examples were the usage of 'if' sentence in Shell language. Here are the tips and samples:
Semantics:
If [conditions]; then
Command
Fi
#! /Bin/bashwhile [1] Do A =$ (ifconfig eth0 | grep 'rx PAC '| awk' {print $2} '| awk-F: '{print $ NF}') echo-ne "$ A \ r" # refresh data done without line breaks
EchoParameter number:-N. Do not wrap the line at the end.-E if the following
The method for listing all Shell objects is not provided below. For more information, see Ishelldispatch: Public idispatch {// you must specify the name of the control panel program. cpl suffix hresult controlpanelitem (BSTR szdir); // causes the
Reprinted statement: This blog article allow free reprint, but reprint need to indicate the author, source: Denny wqf363@hotmail.com Source: www.huntmine.com
Shell-specific variablesTable 14-2 specific s h e l variable $ # number of parameters
Bash cannot handle floating-point operations and lacks specific operations. These operations are important computing functions. Fortunately,BCThis problem can be solved.BCNot only is it a flexible and precise tool with multiple functions, but it
During distributed parallel computing, you often need to upload compiled files to the same directory of each computing node. when there are many computing nodes, this work is quite tedious. the following example shows the script for transferring
Hill sorting is one of insert sorting. The insertion sorting algorithm mentioned in the previous article (click to View Details) should be called "directly insert sorting algorithm ", the hill sorting algorithm introduced here is an improved direct
Lu1 (){Echo 'aaaaaaaaa'}
Lu2 (){Echo 'bbbbbbbbbbbb'}The above is the source code of run. Sh. We can see that there are only two function definitions and there is no place to call these two functions. If we execute these two functions like
Power shell provides the definition function for user variables.
Variables do not need to be declared first (of course, they are in uniformity. For some global variables, we recommend that you declare them first and assign values). The variable
This article is the Second Reading Note of Flow Control in Chapter 5 of Learning the bash Shell 3rd Edition, but we will not limit it to this. Flow control is a common part of any programming language and includes bash. Here, we will continue to
Continue Process Control
This is case. It can match the variable content and multiple comparison characters. If the matching is successful, this part of code is executed. It can only be a string.
The writing structure is as follows:
Case match
I. Shell VariablesIt mainly includes local variables and environment variables.
1. Local variable -- Used in the script currently running by the user1)Define local variablesFormat: variable-name = valueExample: [root @ jike1/root] # LOCALTEST =
A problem occurs in the system. When the VBS script runs, the WScripting. Shell cannot be created.
In fact, some objects created by calling the CreatObject function in VBS are some COM objects stored in DLL files. An error is reported when the DLL
From: http://blog.sina.com.cn/s/blog_7556be720100ryp2.html
CTRL + P repeat the previous command
CTRL + a jump to the first characterCTRL + x same as above, but once again, it will return to the original locationCTRL + B move one character forward
In Linux, It is very troublesome to use ruijie. After installing myxrgsu, you must enter your account and password every time you use it. This process is too cumbersome. So I want to find a way to automatically enter the password and other
Function
Bash does not enable a new sub-shell to call a function. It is executed in the existing shell environment.
Syntax:
Function Name (){Command Area}Function Name (){Command Area}Function Name{Command Area}
Call: function name parameter 1
File Operations
Get directory content
Ls
Getconf ARG_MAX
Determine whether a file exists
Create a file
Create a general file:
Create a file
1 use the redirection output:> text.txt
2. Use the NULL command:> test. xtx to increase script portability.
ShellIntroductionBashProgramming execution
There are five methods to execute a command in the Bourne Shell, and the results of these five methods are different:: Run the following command directly: This method is the same as using the command in
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service