1.Shell programming As with Java, PHP programming, as long as there is a code to write a text editor and a can explain the execution of the script interpreter can be#!/bin/sh (#! tells the system that the program specified after the path is the
First, FTP download the current file according to the date#!/bin/bashdate= ' Date +%y%m%d ' ftp-n Second, upload the current file according to the log#!/bin/bashdate= ' Date +%y%m%d ' ftp-n Three, more and catalog upload download#!/bin/bashdate= '
Shell scripts are usually text files that start with #!/bin/bash. #! is placed before the interpreter path.Use bash as the interpreter to interpret all command-line commands.There are two ways to run a script, one is to use the script as a
The advantage of awk for sed grep is segmentation, dividing the delimiter into a small segment, matching, replacing, manipulating, logical judging, comparing ... such asBasic operations of AWK[[email protected] ~]# awk-f ': ' {print $} ' 1.txt////-F
Shell variables are divided into system variables and user-defined variablescommands to view variables#env System VariablesOr #set include env and custom variables and extra variablesThe command to use the variable is#echo $ "Variable"///////////////
ShellThree ways to do it (not original, forget who's blog) 1: . Filename 1. SOURCE command usage: source FileNameFunction: Reads and executes the commands in the filename under the current bash environment. The filename file can have no "execute
Shell's advantage: You can call Linux system commands directlyBasic syntax for shell scripts:Script name ends with. shThe first action of the program #!/bin/bash, tell the system this is a shell scriptWith # as a commentHow shell scripts are
In the actual work, the shell script needs to be tested for correctness.How to test in the quickest and most effective way?A lot of development habits are, apart, write/Get, run a, see input, output, want to do the operation is completed, also
Sometimes the server vendors will make their own naming rules, such as some of Dell's server network card name may be the beginning of EM, such as EM1, and sometimes the beginning of the ETH, such as eth0, which let us get the network card command
AWK: useful Data processing toolsAwk is also a great data-processing tool! SED is often used for the processing of an entire row, and awk prefers to divide a row into several "columns" ( or, in other words, a column) to handle. Thus, awk is quite
1. grep====================== from Shell script Raiders =================================
Search from file or standard input.
-E (E) (equivalent to egrep ) + "Regular expression" + files
- o (Output matching text only, can be used
Orderdeveloped under the Linux platform, we are often exposed to tasks of the nature of the work, and the processing methods are diversified. Now accumulate each case. Cleaning up the data log files for nearly 7 days is getting bigger, and we need
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
Shell Common Command Summary1 ls command: List filesLs-la list all files and folders in the current directoryLS A * lists all files starting with the A letter in the current directory Ls-l *.txt Lists all files with the suffix txt in the current
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:
The process controls the "if" expression if the condition is true then the following part is executed: if ...; Then....Elif ...; Then....Else....FiIn most cases, you can use test commands to test the condition. For example, you can compare strings,
Because I usually write some small experimental script, every time to write author,description and so very troublesome, then wrote such a script can create their own small script, code as follows, pure personal original, relatively rough, big God
Hill sort (Shell sort)#include using namespace Std;void print (int a[], int n, int i){Coutfor (int j= 0; j{COUT}cout}/* Direct insertion of the general form of the sort ** d Zoom out increment, if is direct insert sort, d=1 */void Shellinsertsort
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