When we are testing or commissioning, sometimes you need to generate a file of size, for example, when testing the storage system, you need to reduce the amount of disk space 5G, the easiest way is to copy a 5G file over, but where to get the size
In simple terms, this technique corresponds to the following scenario
Suppose there is text as follows
Copy Code code as follows:
Cccc
Aaaa
bbbb
dddd
bbbb
Cccc
Aaaa
Now it needs to be processed, this is simple,
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
First, Introduction
Environment variables are typically used to store path lists that are used to search for executables, library files, and so on. For example: $PATH, $LD _library_path, they usually look like this:
Copy Code code as follows:
There are many examples of shell script-reading text files on the web, but they don't tell the whole story, only half of it. For example, read a text line from a testfile file in the following format:
Copy Code code as follows:
$ VI
Test the effect of prefetching, using the CPU to always view the effect. According to the experiment found that the prefetch address in the address before the use of the 10 lines around the code at the effect is better!
Copy Code code as
In the shell script, you find a problem with the case statement.This method of specifying lowercase letters [A-z] and uppercase letters [A-z] is no use.
The following conditions occur:
Copy Code code as follows:
[Root@station1 ~]#
First, the common skills
Copy Code code as follows:
SSH User@server Bash #ssh到远程服务器执行一个脚本, this command avoids uploading scripts to a remote server
SSH User@host Cat/path/to/remotefile | Diff/path/to/localfile-
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
The last time we sent a Python update Google hosts script, today saw someone sent a shell to get Google hosts script, I took to a slightly more simple processing, the following gives you the shell version of the update of Google hosts script.
The company server has been dying for the last two days because of the full memory usage. Really can't stand the old call room to help people to restart, specifically wrote a script to release the memory, of course, this server is not too important,
What I want to say here is the parentheses in several shells, the braces and the bracketed variables, and the use of the command, as follows:
1.${var}2.$ (CMD)3. () and {}4.${var:-string},${var:+string},${var:=string},${var:?string}5.$ ((exp))6.$
A few days ago wrote seven bull demo, with Bash wrote a convenient installation of the script, involving the path-related judgments, from StackOverflow, plus their own practice to tidy up.
Simple version
The following is one of the simplest
awk regular Expressions and built-in function examples are detailed:
1, Fuzzy matching:
Copy Code code as follows:
awk ' {if ($3~/97/) print $} ' DATA.F: Print the line if "97" is included in the third item
awk ' {if ($4!~/ufcx/)
Today, my company colleagues to my entire ADSL automatic redial shell, and detect whether connected to, so as to ensure that the internal test server does not drop the net, OK, I sent the script below.
System: CentOS 5.x
Script 1:
Copy Code
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:./
1. Background
When multiple processes may perform operations on the same data, these processes need to ensure that the other processes are not operating to prevent damage to the data. Typically, such a process uses a "lock file", which means that
Ord functions are not provided directly in awk, so when you convert a character to a code, you need to implement it yourself
Copy Code code as follows:
awk ' begin{for (i = 0; i
This mainly constructs the data structure of
First, simple version
Refer to the example of StackOverflow and change one out:
Copy Code code as follows:
While ifs= ' = ' Read var val
Todo
if [[$var = = \[*]]]
Then
section=$ (echo $var | sed ' s/^\[\ (. *\) \]$/\1/')
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