Pipe the Print("all") result to file in a macro

To see the contents of a histogram I do:


This prints it to screen. Now I want to pipe the result into a file. The following doesn’t work:

newHisto5->Print(“all”); > file.dat

How should I do this in a macro?


Redirection to a file works only at the command line.
You can redirect the output of a macro to a file via
.x macro.C >x.log