Command line for mac os x3/23/2023 ![]() To see the tree output in action, here’s a truncated tree output of my photo library directory: ~/Pictures/Photos Library.photoslibrary$ tree -v -charset utf-8. Here’s my final tree command which I use for my weekly backups: tree -v -L 1 -charset utf-8 > backup-whateverfolder-$(date +%Y-%m-%d).txt A sexy way is to use a date-time expression in a combination with the output file name. If you’re using a daily, weekly, monthly or other scheduled backup, you need to make the backup file more unique. You can also save the tree output bash-like with > backup.txt instead of using -o backup.txt. With the additional argument, -o backup.txt you can save the whole tree output in a file. The command for that is the following: tree -v -L 1 - charset utf-8. In my case, I only needed to list the first directory level with an alphanumerical file sort and utf-8 character encoding for my file output. help Print usage and this help message and exit. Miscellaneous options -version Print version and exit. nolinks Turn off hyperlinks in HTML output. T string Replace the default HTML title and H1 header with string. H baseHREF Prints out HTML format with baseHREF as top directory. J Prints out an JSON representation of the tree. XML/HTML/JSON options -X Prints out an XML representation of the tree. n Turn colorization off always (-C overrides). S Print with CP437 (console) graphics indentation lines. A Print ANSI lines graphic indentation lines. Graphics options -i Don't print indentation lines. sort X Select sort: name,version,size,mtime,ctime. dirsfirst List directories before files (-U disables). c Sort files by last status change time. Sorting options -v Sort files alphanumerically by version. device Print device ID number to which each file belongs. D Print the date of last modification or (-c) status change. si Like -h, but use in SI units (powers of 1000). h Print the size in a more human readable way. g Displays file group owner or GID number. File options -q Print non-printable characters as '?'. ![]() o filename Output to file instead of stdout. timefmt Print and format time according to the format. ![]() filelimit # Do not descend dirs with more than # files in them. charset X Use charset X for terminal/HTML and indentation line output. ![]() noreport Turn off file/directory count at end of tree listing. matchdirs Include directory names in -P pattern matching. ignore-case Ignore case when pattern matching. I pattern Do not list files that match the given pattern. P pattern List only those files that match the pattern given. R Rerun tree when max dir level reached. L level Descend only level directories deep. f Print the full path prefix for each file. l Follow symbolic links like directories. This will print a list with all the available arguments including a short explanation of what each argument can do: ~/$ tree -help usage: tree ] #] ] ] - Listing options -a All files are listed. Now you can test the tree command and see what you can do with the tree tool by executing the command tree - help. If you’re able to install Homebrew, you can install the tree command line tool with the command:brew install tree ~/$ brew install tree => Downloading # 100.0% => make prefix=/usr/local/Cellar/tree/1.7.0 MANDIR=/usr/local/Cellar/tree/1.7.0/share/man/man1 CC=clang CFLAGS=-fomit-frame-pointer LDFLAGS= OBJS=tree.o unix.o html.o xml.o hash.o ? /usr/local/Cellar/tree/1.7.0: 7 files, 128K, built in 4 seconds ~/$ You can read here how to install Homebrew. ![]() To install command line tools like the tree command on Mac, you can use the Homebrew package manager as well. Make The Tree Command Available On Mac OS X This backup shouldn’t contain any physical data, just a simple directory listing.įrom Debian, I already knew the tree command which lists a directory structure recursively. I needed a solution to create a directory listing backup for my external hard drives. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |