The best way to learn AWK is probably looking at some examples in a given context, let us create file data.txt file which has the following content:

File content: data.txt #

Months Water Gas Elec Phone
Jan 647 2851 3310 1200
Feb 287 3544 25500 1000
Mar 238 3212 21900 1710
Apr 468 6986 35000 2000
May 124 1097 96300 13000

Thanks to educative.io team for helping me to apriori upload this file (data.txt) to the Educative storage space. So, you should be good to go, just press the Run button!

Example 1. AWK print function #

By default Awk prints every line from the file.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy