The idea is to learn the code creation is their own very like the first few lines of logic rigorous#!/bin/bash#判断两个整数的大小Read-p "Please enter two integers a B:" A B#或者使用a =$1[-Z "$a"]| | [-Z "$b"]&&{echo "The number you entered is zero"Exit
Shell Programming for loop Summary
In shell programming, the execution of a loop is repeated several times for a piece of code, a common loop has a for, while, and a until loop, where the for loop is often used for finite cycles, and the
Because the shell appears to be a common feature between UNIX systems and is standardized by POSIX.As a result, shell scripts can be applied to many systems once they are "written attentively".Therefore, the shell script is used because of the
This is a very interesting question, because as a shell rookie, I have no idea for the first time. I wonder why this kind of operation Linux actually does not have a direct command to implement such a query.Naturally, the first feeling is to use awk
Change the previous code1. Infer if it is hello, and if so, it shows "Hello, how is it?" ;2. Assume that no number of parameters is added or not. The method that prompts the user to be required to use the number of parameters.3. Assuming that the
Shell Overview:The interpreter program between the Linux kernel and the userUsually refers to/bin/bashResponsible for directing to the kernel to translate and communicate user/program instructionsEquivalent to the "shell" of the operating systemHow
#!/bin/bash- function mytest () { echo "arg1 = $" If [$ = "1"]; then return 1 else return 0
fi}if MyTest 2; Then echo "Aaaaaaaaaa" fi
Execution Result:Change it a little bit.#!/bin/bash-function mytest
If we define a variable as:File=/dir1/dir2/dir3/my.file.txtCan be replaced with ${} to get different values:${file#*/}: Delete the first/its left string: dir1/dir2/dir3/my.file.txt${file##*/}: Remove the last/and left string: my.file.txt${file#*.} :
Tips for ShellThere'll is some case-based tips for Shell.1. Replace The sequence space with newlineInput Examplea b c dOutput ExampleabcdSummarysedis the best solution.Solutionsed -r -e ‘s/[[:space:]]/\n/g‘2. Sort the unordered word list (with
Environment Variables Section:1. View Global variables: printenv/env2. Displays the value of a single environment variable: Echo as Echo $HOME3. Display all environment variables set for a particular process: set4. Setting global variables: Creating
Start the script under $hadoop_home/bin or $hadoop_home/sbin, the shell terminal will display the output information;Based on the output information, the information of Bash-x [Script-name] and the script itself can be used to locate where the error
Suppose we define a variable as:File=/dir1/dir2/dir3/my.file.txtDifferent values can be replaced with ${}, respectively:${file#*/}: Remove the first one/And the string to its left:Dir1/dir2/dir3/my.file.txt${file##*/}: Erase the last one/And the
String interception of Linux is useful. There are eight ways.Suppose there is a variable var=http://www.aaa.com/123.htm.1. # Intercept, delete the left character, leave the right character.Echo ${var#*//}where Var is the variable name and the # is
1.1. Shell BasicsBash is a language interpreter that is compatible with Bourne Shell and executes commands that are read from standard input device files. BASH is the abbreviation for the Bournae-again shell. Bash is backwards compatible with the
The definition format of the function:function Funname (){Actionreturn xxx;}1, can be with function fun () definition, can also be directly fun () definition, without any parameters2, the parameter returns, can display add: return returns, if not
In fact, this is very simple, in the Linux server installed plug-in Lrzsz can:Then, if you want to upload something in that directory, we can use the command RZ directly to solve the problem:Then enter:Select the file you want to upload, and the
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