-1

I would like to accomplish the following using Linux bash and/or Linux utilities.

I'm running Debian 10 on a cloud server.

I have a csv file of the following form:

    "2019-12-10_15-03-50",13,"ivarz_tb",0
    "2019-12-10_15-09-37",13,"ivarz_tb",1
    "2019-12-10_15-09-37",14,"objj_tb",0
    "2019-12-10_15-11-48",14,"objj_tb",1
    "2019-12-10_15-11-48",15,"gateway",0
    "2019-12-10_15-11-48",15,"gateway",1
    "2019-12-10_15-11-48",16,"base",0
    "2019-12-10_15-16-33",16,"base",1
    "2019-12-10_15-16-33",17,"bins",0
    "2019-12-10_23-42-10",17,"bins",0

As you can see, each line has four fields.

I'd like to check the last line and report whether the final field is a 0 or a 1.

I realize I can do this with a traditional programming language such as C++ or Python but I believe that to be overkill for this simple task. I'm a total Linux newbie, however, so I'm unsure as to which tool(s) are best for the purpose. Any recommendations will be gratefully received.

Argent
  • 209
  • 1
    A combination of https://unix.stackexchange.com/a/317922/70524 and https://unix.stackexchange.com/a/192762/70524 – muru Dec 11 '19 at 03:29

1 Answers1

1

@muru Thanks for those leads. Using them, I came up with this one-liner:

tail main_top.csv -n 1 | awk -F, '{print $NF}'
Argent
  • 209