In Python, there are many modules that enable concurrent programming, such as threading, processing, Eventlet, and Stackless python.
So how does it work for the shell? In fact, the principle is very simple, I used the method is:1. The tasks that
By curl the-w parameter we can customize the output of the curl,%{http_code} represents the HTTP status code
The code is as follows
Copy Code
# curl-i-M 10-o/dev/null-s-W%{http_code} www.111cn.net
The above
Using the Linux shell is my daily basic work, but I often forget some useful shell commands and L tips. Of course, I can remember the order, but I'm not sure I can remember how to use it to perform a particular task. So I began to record these
Take. SVN example
For example, if I want to delete all the. SVN directories under/data/web/, then execute the following command.
The code is as follows
Copy Code
Cd/data/webFind. -type d-name ". SVN" |xargs RM-RVF
A date loop that is useful in processing some data that is stored by date. Especially testing and recording, deleting, reprocessing data. However, if you encounter a situation such as the span of a month, simply using a numerical cycle is not
In the shell, $* and [email protected] respectively represent the following meanings:$ A: The name of the script itself$#: Number of positional parameters$*: All positional parameters will be treated as a string[Email protected]: Each positional
Variable
Meaning
$
Gets the file name of the current execution shell script
$n
Arguments passed to the script or function. N is a number that represents the first few parameters. For example, the first
See if there are any custom users (ordinary users) on your Linux system, and if so, how many are there?[email protected] ~]# cat 6.sh#/bin/bashN= ' awk-f: ' $3>=500{print '/etc/passwd |wc-l 'If [$n-gt 0];thenecho "$n Common users"Elseecho "No common
The shell is the interface that the user interacts with the system, which is one of the basic ways. The standard shell is bash.Shell's Operation:
Show all used commands: history.
Execute a command that has been recently executed:!!。 The
Variable Description:$$ The PID of the shell itself (Pro CESSID) $! PID of the last background process run by the shell $? End code of the last command run (return value) $- Flag list set with the SET command $* All parameter lists.
1. Basic Regular Expressions1.1 regular expressions and wildcard characters(1) A regular expression is used to match a string that matches a condition in a file , and a regular contains a match . grep, awk, sed, and other commands can support
PS: This iptables script is good, very practical, according to the actual application changes can be used by themselves. Share it for everyone to reference. Original author Anonymous. The source code is as follows:#!/bin/sh#Modprobe
Globbing: File name wildcard (whole file name match, not part)Match pattern: metacharacters*: matches any character of any lengthpa*, *pa*, *pa, *p*a*PA, PAA, passwd?: matches any single characterPa??? PA, P?a, P?a?PA, PAA, passwd[]: matches any
The shell command can be executed directly in awk.[Plain]View PlainCopy
[Email protected]:~$ Touch A
[Email protected]:~$ Touch b
[Email protected]:~$ cat A.txt
A
B
[Email protected]:~$ awk ' {cmd= ' rm ' $0;system (CMD)} ' A.txt
Write at the beginning, always write wrong, seemingly simple function, but must be careful; function definition:Funciton functionname {...} There must be a space between functionname and {! I just did not add a space, has been an error.Implement two
Nginx log access. log is not separated, and access records are always recorded in this file. For a long time, log query and file system are not good, so segmentation is required.Vim/data/scripts/cut_nginx_log.sh #! /Bin/bash# Auto-run this
Replacing File content in Centos in batchesThese two Angels used the locomotive to collect some data because they generated a lot of SQL files. I want to replace the fixed content in each SQL file with another content.Manual file configuration
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.