On the previous post we’ve talked about sed Linux command and we’ve seen many examples of using it in text processing and how it is good in this, nobody can deny that sed is very handy tool but it has some limitations, sometimes you need a more advanced tool for manipulating data, one that provides a more programming-like environment giving you more control to modify data in a file more robust. This is where awk command comes in.
The awk command or GNU awk specifically because there are many extensions for awk out there takes stream editing one step further than the sed editor by providing a programming language instead of just editor commands. Within the awk programming language, you can do the following
- Define variables to store data.
- Use arithmetic and string operators to operate on data.
- Use structured programming concepts and control flow, such as if-then statements and loops, to add logic to your text processing.
- Generate formatted reports
Actually generating formatted reports comes very handy when working with log files contain hundreds or maybe millions of lines and output a readable report that you can benefit from.
our main points are:
command options
Reading the program script from the command line
Using data field variables
Using multiple commands
Reading the program from a file
Running scripts before processing data
Running scripts after processing data
Built-in variables
Data variables
User defined variables
Structured Commands
Formatted Printing
Built-In Functions
User Defined Functions
https://likegeeks.com/awk-command/
Hope you like it
Thank you