Skip to content

Instantly share code, notes, and snippets.

@mariolopjr
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariolopjr/c6aaa4b99c553bec6916 to your computer and use it in GitHub Desktop.
Save mariolopjr/c6aaa4b99c553bec6916 to your computer and use it in GitHub Desktop.
Alternative `tree`, suing only find and awk
#!/bin/bash
#
# Alternative to `tree`, lists directories/files in current directory
# Original credit to jweyrich from Stack Overflow: http://superuser.com/a/409654
# Edited by Mario Lopez
#
find $1 -print 2>/dev/null | awk '!/\.$/ { \
for (i=1; i<NF; i++) { \
printf("%4s", "|") \
} \
print "-- "$NF \
}' FS='/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment