Wednesday, April 6, 2016

AWK Scripts - Examples

Example 1:

{
  if (match($0,/stat\.X[0-9][0-9][0-9]/)) tab = substr($0,RSTART+6,RLENGTH-6);
  if (tab + 0 >= 70 && tab + 0 <= 120) { print tab; }
}

Script does:
  • For every line like statA.X023, sets the variable 'tab' to the number, here 023
  • outputs the number if it is between 70 and 120

No comments: