0

Under macOS Catalina 10.15.1, Using the standard "tree" command (as supplied by MacPorts), if at the Terminal prompt I cd to a folder and then execute tree there, I get output like this:

.
├── Activity\ Monitor.app
├── ApplicationsFolderIcon.icns
├── BBEdit.app
├── Backup
│   ├── Backup\ and\ Sync\ from\ Google.app
│   ├── Carbon\ Copy\ Cloner.app
│   ├── Dropbox.app\ 
│   ├── ForeverSave\ 2.app
│   ├── Get\ Backup\ Pro\ 3.app

However, if I redirect the output to a text file, as in

tree > myapps.txt

then I get wrong characters when I view the file in TextEdit:

.
├── Activity\ Monitor.app
├── ApplicationsFolderIcon.icns
├── BBEdit.app
├── Backup
│   ├── Backup\ and\ Sync\ from\ Google.app
│   ├── Carbon\ Copy\ Cloner.app
│   ├── Dropbox.app\ 
│   ├── ForeverSave\ 2.app
│   ├── Get\ Backup\ Pro\ 3.app

What's wrong?

  • Try > myfile.rtf – anki Dec 10 '19 at 19:01
  • I tried that (writing to ~/Desktop), and the file gets written...BUT even though I see the file on the desktop, when I try to open it, either by double-clicking it I get a pop-up error 'The document "myfile.rtf'' could not be opened'. – murray Dec 10 '19 at 19:54
0

Use either of these to get compatible characters.

tree --charset=ascii > a.txt
tree --charset unicode > a.txt

https://unix.stackexchange.com/questions/127063/tree-command-output-with-pure-7-bit-ascii-output

| improve this answer | |
  • With default Preferences for TextEdit.app, the version with tree --charset=ascii and redirecting to a file is working perfectly. Thank you! – murray Dec 10 '19 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .