So the traditional way to dump a directory listing to text is to use a command such as the following:
ls > test.txt
But there’s another way, which actually opens the dump into TextEdit, which is to run:
ls | open -tf
This extends to the output of any terminal command, so you could also do scutil –get HostName | open -tf, etc.