Transfer from http://www.cnblogs.com/dwdxdy/archive/2012/07/25/2608816.htmlThe style files are often processed on a line-by-row basis, how to get each row of data in the shell, then process the row data, and finally read the next row of data, loop
For C in a B C D E F g;do echo $c; Done sequentially outputFor C in a B C D E F g;do tar czvf install.log. $c. tar.gz Install.log; DoneFor C in {a.. g}; do echo $c; Done the same as aboveSeq 1 10 columns of numbersFor i in {1..10}; do echo $i;
Write a script that calculates all the odd and all the even numbers within 100 and displays them separately#! /bin/bashSum1=0For i in ' SEQ 1 2 100 'Dosum1=$[$sum 1+ $i]Doneecho $sum 1Sum2=0For j in ' SEQ 2 2 100 'Dosum2=$[$sum $j]DoneEcho $sum
1:declare commandshell Default is String typeIf subtraction is required, it needs to be defined as an integral typeDECLARE command: Change the default variable type Decalre [+/-] [option] Variable name-set type properties for variables+ Cancel
(1) Write a script: If a path does not exist, it is created as a directory, otherwise it is present, and the content type is displayed#!/bin/bash#if [$#-lt 1]; Then echo "Plz Enter a path:" Exit 1fi if [-e $]; Then file $1else mkdir-p $1fi ~Test
if condition judgment; ThenStatmentElseStatmentFiOrif condition judgment; ThenStatmentElifStatmentFiAnti-quote: Returns the execution result of the command to the variable.Set UserIDUserID = ' Id-u user1 'command to end a script prematurely: exit:
In addition to ordinary characters in the shell, there are many characters with special meanings and functions.1. Wildcard characters* : string of any length? : Matches any single character[]: Matches any one of these characters, for example:[ABC]
Directory:First, the operation Principle of shell programSecond, Shell common skills1. Command history2. Command aliases3. Command Reference4. File name Wildcard5. Common shortcut keys6. Complement function7. Input and output redirection and piping8.
#!/bin/bash# defines greatest common divisor and the minimum number of conventions gcd_result= "lcm_result=" "#定义一个相加的函数function sum () { result=$ ( num1+num2 ) echo -e "\033[31m two number of $result \033[0m"}# Define a greatest common
1.cdCD-Back to last catalogCD returns the current user's home directory2.mkdirMkdir-p Creating a multilevel directoryEg:mkdir-p Test1/test2/test33.findFind-empty Finding empty DocumentsFind-user XXX View all information about user xxxFind-mtime-1
First, homework (exercise) content:1. Describe the operation principle of shell program (can be attached with necessary graphic instructions);2, summarize all the knowledge points involved in shell programming (such as: variables, grammar, command
Read Catalogue
Numerical test
File test
String test
The test command in the shell is used to check if a condition is true, and it can be tested in three ways, such as numeric values, files, and characters.
List the number of connections per IPawk ' /^tcp/{print} ' awk ' !/^::/{print $ {} ' Sort Uniq Sort awk ' begin{printf "%-10s%s\n", "Connum", "IP"}{printf "%-10s%s\n", $1,$2} 'Command explanation:
Netstat-n refused to display aliases, can
Key
function
Ctrl+d
Keyboard input end or exit terminal
Ctrl+s
Tentative current program, pause and press any key to resume operation
Ctrl+z
Put the current program in the
Too lazy, these days seem to have been lazy cancer, do not want to write a blog. Later think about, knowledge, or share the good. The first to cure their own lazy cancer; second, consolidate your knowledge by the way.
There are two types of
In order to match the previous text, here first to organize a key how to deploy LNMP environment;In fact, small and medium-sized enterprises in the production environment is also very like to use such software packages, because after all, the source
This article is intended to review the definition and assignment of arrays in shell script programming, to read arrays, and to get the length of an arrayKnowledge Reserve
Array : Multiple contiguous separate memory spaces, each memory
Encounter FTP to more than one machine problem, waiting for the last execution to execute the next, time will be longer, if you can simultaneously send files to multiple machines, you can achieve the purpose of saving time.Grammatical
PackageCom.edu.hpu.sort.insert.shell;Importjava.util.Arrays;ImportCom.edu.hpu.sort.Sort; Public classShellsortextendsSort {@Override Public int[] Dosort (int[] arr) { intLen =arr.length; //all step probabilities (for the first half of 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