Passing a parameter to root macro

Hello,

I have a number of root data files, containing
root histograms in a subdirectory, like

ef@pc1000 macros]$ ls -1 his*.root
his89390.root
his89391.root
his89392.root
his89393.root
his89394.root
his89395.root
his89721.root

I am using a root macro to process individual files,

void autcheck(Int_t nr=89390){
TFile file(Form(“his%d.root”,nr)); // current histos

---------do something-----------
}

I can process an individual *.root file from the
Linux prompt via

ef@pc1000 macros]$ root autcheck(89721)

My question: I would like to process the last *.root
file, (one with the highest number, in the above example
his89721.root). What would be the most elegant way
to do it automatically, without having to do the ‘ls’ command,
see what is the latest *.root file, and then type in the
number as a parameter, as in example above, root autcheck(89721)?

In another words, how can I pass the name of the latest
his*.root file inside the autcheck.C root macro automatically?

I can get that file from the linux prompt in many ways,
like: awk ‘{line = $0}; END {print line}’, but I don’t
know how to pass it to root macro ;:sunglasses:

                                     Cheers, Emil

Hi Emil,

You can use something like:root.exe -b -q -l "autocheck.C(\"`ls -rt | tail -1`\")"

Cheers,
Philippe