Friday, June 22, 2012

Tree command in Mac

Linux and probably other Unix-y OSes have this nice "tree" command to list a directory in a nice tree view in command line interface. But Mac is missing that. There are plenty of workarounds using the "find" and "ls -R" command for this but I found the one below good enough for me:

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

I just created an alias in my bashrc file and enjoying it :)

alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"