htop author here.
No, there’s no “nice” way to get the output of htop piped into a file. It is an interactive application and uses terminal redraw routines to produce its interface (therefore, piping it makes as much sense as, for example, piping vim into a text file — you’ll get similar results).
To get the information about your processes in a text format, use “ps”. For example, ps auxf > file.txt
gives you lots of easy to parse information (or ps aux
if you do not wish tree-formatting — see man ps
for more options).