Help with awk command on report with headings

Hi all, I have a report that looks like this:

-------------------------------------------------
--                AOC - XXXXXXX                --
-------------------------------------------------

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                  64069                 64069          0


-------------------------------------------------
--                AOC - XXXXXXXXX              --
-------------------------------------------------

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                 259202                259202          0


-------------------------------------------------
--                AOC - XXXXXXXX               --
-------------------------------------------------

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                  77523                 77523          0

If I only care about the Difference field (the last one). How do I use the awk command to skip the headings and just concencreate on the numerical lines of data?

Not quite sure what you're after. Is that one single file with subsections and respective headings, and you just want the last field of the data lines only? Any attempts / ideas / thoughts from your side? Any preferred tools?

That report is one single file. I know how to get awk to give me the last field (Difference) if there were no headings. What I don't know how or if I and do is skip the headings and column names and just go after the data.

making assumptions based on a sample file:

awk '$NF!~"^--" {print $NF}' RS= myFile

If there are but digits and spaces in the lines of interest:

awk 'NF && !/[^0-9 ]/ {print $NF}' file

Thanks everyone. I'll try it.

Yet another awk recipe...

awk '{if($NF+0) print $NF}' file

not when $NF is 0

1 Like

When I do this command as shown above:

awk '$NF!~"^--" {print $NF}' RS= myFile 

then it does only get the difference field but it still prints the Difference column name. I'm hoping to just the the value of the difference field.

strange - I get only the value (no header) given your sample file.
Could you post the output of cat -vet myFile using code tags.

Good catch...so here's the updated awk recipe:

awk '{if($NF==0 || $NF+0) print $NF}' file
1 Like
^I^I^I     ------------- ORACLE STANDBY SYNC REPORT 08-OCT-2018 14:50:45 ------------$
$
$
$
$
$
-------------------------------------------------$
--^I^I  AOC - XXXXXX ^I       --$
-------------------------------------------------$
$
    Thread Last Sequence Received Last Sequence Applied Difference$
---------- ---------------------- --------------------- ----------$
^I 1^I^I    64081^I^I  64081 ^I 0$
$
$
-------------------------------------------------$
--^I^I  AOC - XXXXXX^I^I      --$
-------------------------------------------------$
$
    Thread Last Sequence Received Last Sequence Applied Difference$
---------- ---------------------- --------------------- ----------$
^I 1^I^I   259214^I^I 259214 ^I 0$
$
$
-------------------------------------------------$
--^I^I  AOC - XXXXXX^I^I      --$
-------------------------------------------------$
$

------ Post updated at 10:44 AM ------

This one worked: awk '{if($NF==0 || $NF+0) print $NF}' file

Much appreciated for everyone for th help!!!

what OS are you on?
Works fine with gawk under Linux....