Linux AWK command Advance CLI

Greeting everyone ! Hope Every thing is going good Today In this blog we are going to see How to Use AWK command is CLI Scripting language which use for manipulate data from given file and string and which easily generating report. In this blog you will learn How to utilize AWK command Interface .

what is AWK ?

Basically AWK Is command which based on domain specific which design for text processing as which used for Manipulate data and reporting tool. its work as filter which is default in any linux/unix system. The version of AWK that GNU/Linux distributes is written and maintained by the Free Software Foundation (FSF); it is often referred to as GNU AWK.

Advantages Of AWK ?

It scan file One by one Line
Splits each input line into fields
It Compares input line/fields to pattern.
Performs actions on matched lines as user supplied .
Its based on Arithmetic and string operations.

AWK is very simple to use we can use AWK from our command Line Now, to check AWK Is installed in Your OS Or not run command : -> awk -h (it will give instruction of Usage of awk)

Now assume we have file.txt which contain following data

1.pallab class 23
2.sam class 25
3.rahul class 2
4.jerry class 4
5.meaco class 5

Now Let’s print all data from given file using awk which we can Utilize here we will use command: -> awk ‘print’ file.txt

Now, Utilize awk to matches the given patter here it will match string according to user want here , we will use command: awk ‘/your match/ {print}’ file.txt

As above result we see we manipulate replace One can use the above syntax for printing lines with a specific pattern. For example, if you want to print lines having the letter ‘o’ you have to add simply add ‘o’ in place of “variable to be matched”.

Now print line from given file using awk which have more then 18 length value AWK provides a built-in length function that returns the length of the string according to user supply. here we will use command: awk ‘length($0) > 18’ file.txt

As above result we see using awk we manipulate value by supplying length 18 that Eg: we need line which have more then 18 length value if a line has more than 18 characters, then the comparison results true and the line gets printed.

As We discussed Basic about AWK Programming As how we can interface using awk using our cli . Awk command in Linux helps the programmer to write a useful program. hope You learned Something new..

For References :

Thanks For Reading……. See You In Another Blog!

Stick With Our Blog :

Author : Pallab Jyoti Borah | VAPT Analyst

Leave a Comment

Your email address will not be published. Required fields are marked *