This chapter mainly explains the number of statistical words.
Count the number of a string in a file, in fact, it can be seen in a piece of sand to find stone, someone saw a stone, in the above do Mark grep, and then remember how many marks; when someone saw a stone, they dug it (TR) and finally counted how many stones they dug. Jump over It (awk) and count how many times you jump.
Cat file
Hafsdha
Hahafsdfsdhaha
haha
If I wanted to match the string ' haha '
-O option for 1.grep
The first time is to use the-C option, but the-C can only count a row, if there is more than one row of matching strings, then-C can do nothing.
This is the right one.
[Email protected] test]# grep-o ' haha ' file | Wc-l
3
[[email protected] test]# awk-v rs= ' haha ' END {print--nr} ' file
-V to set the value of a variable, RS is the record delimiter, the default is a new line (\ n), that is, awk reads the data in one line, but now RS is ' haha ', press ' haha ' after reading the data, NR is the number of read records, N records are separated by n-1 separators, So it's Nr.
Strictly speaking, TR cannot match a string, only to match a single character. This matches the number of ' H ' in this file.
[Email protected] test]# tr-cd ' h ' <file | Wc-c
8
[[email protected] test]# grep-o ' h ' file | Wc-l
8
-D can delete a character, and if only-D outputs the string after the deletion of a particular character, but-C can be reversed, which is the display of the deleted character. Then use the Wc-c to count the number of characters.
To write a Linux driver: 1. Build the Linu x drive skeleton (load and unload Linu x drive). 2.: Register and unregister the device files. 3. Specify driver-related information. 4. Specify the callback function. 5. Write the business logic. 6. Write the makefile file. 7. Compile the Linux driver. 8. Install and uninstall Linux drivers.
Android Driver Development Sixth chapter notes