Getline of awkTo learn more about getline, you must first understand the concepts of $0, NR, and FNR.The so-called NR can be interpreted as Number of Record, or a row Number, while FNR can be interpreted as Number of Record in File or a row Number in the File. It sounds no different. In fact, if you only have one file for awk processing, NR and FNR are the same t
-character string to multiple four-character strings.
// A string up to 12 characters can be entered.
Private String [] fenJie (String numStr)
{
Int numLen = numStr. length ();
// The judgment should be broken down into several four-character strings
Int temp = (numLen + 3)/4;
String [] s = new String [temp];
For (int I = 0; I
S [I] = "";
For (int I = 0; I
{
S [(numLen-1-i)/4] + = numStr. charAt (I );
}
Return s;
}
// The amount of the decimal part
Private String toHan (String numStr)
{
String
; // process's AIO context linked listStruct kioctx default_kioctx;}
AIO Ring
The AIO context kioctx object contains an important data structure AIO Ring:
// Aio. h// AIO Ring# Define AIO_RING_PAGES 8Struct aio_ring_info {Unsigned long mmap_base; // starting address of the AIO ring user StateUnsigned long mmap_size; // buffer LengthStruct page ** ring_pages; // a pointer array of the AIO ring pageSpinlock_t ring_lock;Long nr_pages;Unsigned nr
awk commandawk, like SED, is a streaming editor that operates on lines in the document, one line at a line. Awk is more powerful than SED, and it can do what sed can do. The awk tool is actually very complex and has special books to describe its use.1 awk Command Formawk [-f|-f|-v] ' begin{}//{command1; Command2} end{} ' file[-f|-f|-v] Large parameter,-F specify delimiter,-F call script,-v define variable Var=value' Reference code block 'BEGIN Initializes a block of code, primarily referencing g
a length of 4096. A small module below can read the value of Pidhash_shift.--------------------------------------------------------------------------------------------
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7
cat/proc/kallsyms | grep pidhash_shift
8 unsigned int *p_shift = (unsigned int *) 0xc176ab0c;
9
Ten static int __init hash_size_init (void)
11 {
---printk ("Pidhash_shift----------------->%u\n", *p_shift);
---return 0;
14}
interrupt function, which is essentially initializing an array of elements
void Open_softirq (int nr, void (*action) (struct softirq_action*), void *data)
{//NR is the soft interrupt vector number
Softirq_vec[nr].data = data;
Softirq_vec[nr].action = action;
}
Where the kernel registers
|uniq-c |sort-nr | head-207, sed another usage finds the current line, and then modifies the parameter following the line: Sed-i '/selinux/s/enforcing/disabled/'/etc/selinux/configsed colon sed-i ' s:/ Tmp:/tmp/abc/:g ' test.txt means to change/tmp to/tmp/abc/. 11. Print out the maximum and minimum value of a file: Cat a.txt |sort-nr|awk ' {}end{print} nr==1′cat
being processedawk ' {if (argind==1) {print $} if (argind==2) {print $}} ' aaa.txt Bbb.txt # First scan the AAA file and then scan the BBB fileNR number of records that have been readawk ' Nr==1,nr==5{print} ' Aaa.txt # shows 1 to 5 lines of aaa.txt filesFNR the number of records in the current fileawk ' Nr==fnr{print ' a '}
determine whether the size is greater than 90, if more than 90 send mail alarmWhile sleep 5mDoFor i in ' df-h |sed-n '//$/p ' |awk ' {print $ ' |sed ' s/%//g 'DoEcho $iIf [$i-ge];thenecho "More than 90% Linux for disk space, please linux SA Check linux disk!" |mail-s "Warn linux/parts is $i%" [EMA Il protected]FiDoneDoneAnnotations: Using while ...; Do ...; Done is a while loop, and for, while, until, if, and conditional statements can refer to the following articles: http://www.cnblogs.com/che
commands, functions, and expressions, separated by a newline or semicolon, and enclosed in curly braces. There are four main parts: ? Variable or array assignment ? Output command ? Built-in functions ? Control Flow Command 4. awk 's environment variablesTable 1. AWK's environment variables
Variable
Describe
$n
The nth field of the current record, separated by FS between the fields.
$
The complete input record.
ARGC
environment variable Table 1. AWK environment Variables
Variable
Describe
$n
The nth field of the current record, separated by FS between the fields.
$
The complete input record.
ARGC
The number of command-line arguments.
Argind
The location of the current file in the command line, starting at 0.
Argv
An array that contains the command-line arguments.
IP address: Cat access.log |awk ' {print $} ' |sort|uniq-c |sort-nr | head-207, sed another usage finds the current line, and then modifies the parameter following the line: Sed-i '/selinux/s/enforcing/disabled/'/etc/selinux/configsed colon sed-i ' s:/ Tmp:/tmp/abc/:g ' test.txt means to change/tmp to/tmp/abc/. 11. Print out the maximum and minimum value of a file: Cat a.txt |sort-nr|awk ' {}end{print}
any other command can be done by awk (though some may be more complex to write). This example is no exception:
awk ' nr==fnr{a[$0]++} nr>fnr!a[$0] ' 1.txt 2.txt
Find the same part between two files to use
awk ' nr==fnr{a[$0]++} nr>fnra[$0] ' 1.txt 2.txt
The following two statements can also be replaced by:
awk '
In the process of learning C language, we may rarely write variable parameter function, the impression that the university teachers do not seem to have mentioned, but I found that the variable parameter function is very clever, so it is specifically to analyze the implementation of the variable parameter function principle. Without the support of standard C, we write our own code to implement it.
Let's take a look at an implementation code:
#include
#define Va_list void*#define VA_ARG (ARG, typ
fileawk ' End{print FILENAME} ' datafilePrint file nameIf more than one input file can be used to determine, such as:awk ' if (filename== "File1") {arr[$3]=$1}else{($ in arr) {print arr[$1] "|" $ file1}} file2Note: awk processes the previous file before processing the subsequent fileArgindCurrently processed parameter markersARGCNumber of command line argumentsArgvCommand line parameter arrangementENVIRONSupport for the use of environment variables in queuesNextThe next command does not execute
Tags: multiple delimiter reference command blank line type print greater than waterawk 一种编程语言Syntax format: awk "option" ' Pattern{action} ' "File" ... awk [option] ' condition {action} ' [file] ...Note: There must be at least one space between each element in the awk command and in subsequent options and filesOption Description:
parameter Options
Explanatory notes
-F
Specify character characters delimiter
-V
Define or modify a
to determine whether the size is greater than 90, if more than 90 send mail alarmWhile sleep 5mDoFor i in ' df-h |sed-n '//$/p ' |awk ' {print $ ' |sed ' s/%//g 'DoEcho $iIf [$i-ge];thenecho "More than 90% Linux for disk space, please linux SA Check linux disk!" |mail-s "Warn linux/parts is $i%"[Email protected]FiDoneDoneAnnotations: Using while ...; Do ...; Done is a while loop, and for, while, until, if, and conditional statements can refer to the following articles: http://www.cnblogs.com/ch
advantage of the Tasklet implemented by SOFTIRQ.Let's look at SOFTIRQ's registration triggering and distribution processing1 Soft Interrupt RegistrationSOFTIRQ Registration uses the function OPEN_SOFTIRQ, similar to the REGISTER_IRQ of hardware interrupts. Defined in the KERNEL/SOFTIRQ.Cvoid Open_softirq (int nr, void (*action) (struct softirq_action *)) { softirq_vec[nr].action = action;}It is simple t
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.