cut operation is not helping me much

hi,
i have a file where I want to extract the the failure count [4th column]only from the file.

JOB_NAME                          STATE            RUN_COUNT FAILURE_COUNT
------------------------------ --------------- ---------- -------------
OFS_BALA_BILLING_IN                SCHEDULED           22992             0
OFS_BALA_BILLING_IN_NEW        SCHEDULED            22992             0
OS_BAL_MPRTD_IN                    SCHEDULED            22992             0
OS_TO_BALA                            SCHEDULED            22992             0
SAAS_TO_BAL_MPRTD                SCHEDULED            22989             0

I was trying with cut -d" " -f 4 filename[there is TAB in between " "]
it did not work and coming as :

      0
 
      0
    22992
      0

expected is>> only 0s should come.
I tried with cut -c 70 even its not working as expected.
its because cut -c cuts the file according to its character postion and the JOB_NAME in the file are not of similar length.

Please help.

---------- Post updated at 04:54 PM ---------- Previous update was at 04:52 PM ----------

please note that,
the columns are tab separated.
while copy pasting here, its looking like a mesh.. but in original file, all are aligned well.

awk '!/-/{print $NF}' file

If the fields are truly tab separated, You can try cut without providing the "-d" option. the default is tab.
just do cut -f4

@danmero..
Thanks buddy.. i got it working

@Anchal,
Thanks for the reply.
And yes I have tried that way too. but its giving me same unexpected result.[i think the reason is where the length of the first column is little smaller then, automatiaclly the next column wud be 2 TABs separated]
Please rectify, if i am wrong.

The "awk" in post #2 should work because it doesn't care whether white space is tabs or spaces or multiples of either character.

I believe that there must be more than one consecutive tab character in some of your white space.

Please post the output from this "sed" command which is designed to make control characters visible (such as tab characters):

sed -n l filename

Thanks Methyl,
YEs u r true. Thanks for the tips. :slight_smile:

OFS_BALA_BILLING_IN\t       SCHEDULED\t    22992\t      0$
OFS_BALA_BILLING_IN_NEW        SCHEDULED\t    22992\t      0$
OS_BAL_MPRTD_IN \t       SCHEDULED\t    22992\t      0$
OS_TO_BALA\t\t       SCHEDULED\t    22992\t      0$
SAAS_TO_BAL_MPRTD\t       SCHEDULED\t    22989\t      0$

That's why the "cut" misbehaved.

The "awk" approach is best because it copes well with mixed and variable length white space.