1. Extract pattern from file and do sum of all entries matching the pattern
Here $3 is which column is to get sum of. Idea is to grep a certain pattern from file from each line and then process output by awk to get sum of column 3.
idle_power.txt looks like this:
2.345E-6 3.45E-4 1.6078E-3 Sequential …
1.345E-6 2.45E-4 3.6078E-3 Sequential …
2. Count a pattern match – in this example Leprofesseur to be matched in file.txt
3. Split line and then print – in this example split with “:” and print 5th column
$0 – gets whole line, a – array contains split column value per line, : – separator for split, default is space.
4. Find a pattern from file, print certain columns, and sort the output
929 total views, 5 views today