就是一篇普普通通 bash, awk, seed 等程序的学习笔记。
Bash
Variables
Assignment:
|
For Loop
Basic syntax:
|
Also, nested for loop:
|
While loop
This time, take standard output of cat as an input:
|
grep
A program searches input that match a paritular pattern or regular expression.
|
sed
A text stream editor.
|
Example:
|
Inserts line following detection of pattern:
|
Deletes from line number n to end of file:
|
When we have two patterns:
|
awk
A ultility for processing structured text files. It regards each line in a file as a record and broken into fields. Good to parse tables.
Usage: pattern {action}
|
Note:
BEGIN and END forms some sort of loop.
Use ( and ) for selection.FNR refers to the record number(the line number)NR refers to the total record number
When working across file, FNR resets back to 1 but NR keeps increasing.
Wildcard
- any character zero or more times
? any single character
[] a range of characters
{hello, world} exactly one word
Wilcard can be combined.
除另有声明外,本博客文章均采用 知识共享(Creative Commons) 署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。
