Description: The subscript for an array in the shell defaults to the 0 start
1, put the string in the array, get its length
Copy Code code as follows:
#!/bin/bash
Str= "A B--n D"
Array= ($STR)
length=${#array [@]}
Echo
Copy Code code as follows:
#! /bin/sh
# filename killcpu.sh
If [$#!= 1]; Then
echo "USAGE: $ "
Exit 1;
Fi
For i in ' seq $ '
Todo
Echo-ne "
i=0;
While True
Todo
i=i+1;
Done "| /bin/sh &
pid_array[$i]=$!;
Done
I said, the shell is my conventional weapons, although not yet proficient, but I love the shell of the language, under Linux mixed, always write a script. Programmers have genes, there is a preference for programming languages, you let me write C
=================================================
This article for Khler original, reprint must ensure that this article complete and completely retain the original author information and this article original
Today there is a server A to transfer all the Web site program to another server B up, but away from work time is only 1 hours, in order to work on time, simply wrote a shell script to monitor whether there is transmission, I first in the server a
Process state variables
1, $$ get the current shell process number (PID)2, $! executes the PID of the previous instruction3, $? Gets the return value that executes the previous command (0 is a success, Non-zero is a failure, this is very common)4. $
1. Show the top 10 processes consuming memory/cpu
Copy Code code as follows:
PS aux | Sort-nk +4 | Tail
PS aux | Sort-nk +3 | Tail
2. View process
Arrange by memory from large to small
Copy Code code as follows:
SHC can be used to encrypt shell scripts, which can be converted into an executable binary file. After SHC the shell script, it generates two new files at the same time, one is the encrypted executable binary (the filename ends with. x), and the
Purpose of interprocess communication
Data transfer: A process needs to send its data to another process, sending data between a byte and a few megabytes.Shared data: Multiple processes want to manipulate shared data, one process changes to shared
1. Preface
In the actual development process, each module will involve some common functions, such as reading and writing files, search, sorting. In order to reduce the redundancy of the Code and improve the quality of the code, these common parts
function can make a similar custom execution command in shell script, the biggest function is to be able to simplify many of our program code. It is important to note that the shell script is executed from top to bottom/left to right, so the
The string interception of Linux is useful. There are eight different ways.
Suppose there are variable var=http://www.aaa.com/123.htm.
1. # Intercept, delete left character, keep right character.
Copy Code code as follows:
Echo
It is not a programmer's job to tailor an icon of every size needed to the shelves one at a time before the app is put on the shelves, and using the SIPs tool from the MAC can solve this requirement.With respect to SIPs, the following information
The Asia Pacific Network information is recorded here, updated every day.
Http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
The following script will edit this text, output several major network segments of the domestic operators.
Script A (test example 1)
Copy Code code as follows:
#!/bin/bash
Echo ' Your are in the '
Q) Call another script file in the current script file?
Method One: Using sourceScript second (test example 2)
Copy Code code as
Because the local area network host many, the VLAN also many, for often can know the number of on-line host, writes the script to examine the on-line host.
The effect is: the host online display green, the host offline display red results.
Usage:./
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.