I'm creating a text file via terminal by running ls -tr > file.txt
It would be great to import/copy the contents of this text file into a specified column in Numbers.
The end goal is to have a spreadsheet that is updated from various .txt files into various columns representing the directories the .txt files came from.
Any ideas to get me started would be great! I can't seem to find a solution to get the data out of the .txt file into Numbers to start.
Numbers can open a plain text CSV (comma separated values) files.
Importing them in to specified columns may be more difficult.
But CSV files are relatively easy to work with (if your data is sufficiently simply that it doesn't require a bunch of quoting), so you could adjust the data to match the table columns which would make importing it much easier.
Numbers will also treat tab as "next column" and return as "next row" when you paste. So you could generate your listings entirely within KM, using tabs and returns to separate your items, and simply paste everything in.
Also -- if you want a single-column list of the names of the files in a directory (and still want to use the command line to do it), use ls -1 -tr (you can use ls -1tr, but the extra space makes things clearer).
That sounds like a good path if the intention is to add this to an existing table.
Have Keyboard Maestro read the text file, process it so the columns match and are separated by tabs, and then save the result to the clipboard, then just Paste in to the table.