mirror of
https://github.com/Hizenberg469/Makefile-tutorial.git
synced 2026-04-20 06:12:23 +03:00
37 lines
937 B
Plaintext
37 lines
937 B
Plaintext
AWK
|
|
|
|
* searches files for lines that contain certain pattern
|
|
* performs operation described in AWK body on line with certain
|
|
pattern.
|
|
* performs operation described in AWK body on choosen line
|
|
|
|
|
|
* Basic structure
|
|
|
|
awk 'program_you_will_write' input-file1 input-file2
|
|
|
|
awk 'BEGIN{
|
|
code_in_BEGIN_section
|
|
}
|
|
|
|
{ code_in_main_body_section }
|
|
|
|
END{
|
|
code_in_END_section
|
|
}' input-file1 input-file2
|
|
|
|
* AWK Commands
|
|
|
|
* In AWK body bash features doesn't work
|
|
* Completely new language in AWK body
|
|
* print
|
|
* if-else
|
|
* for loop
|
|
* ...
|
|
|
|
* Completely new features we can call on specific line (specific text)
|
|
* NF (number of fields)
|
|
* NR (number of records)
|
|
* RS (records separator)
|
|
* $1,$2,.. (specific fields)
|
|
* ... |