Skip to content

Instantly share code, notes, and snippets.

@michalbcz
Created September 5, 2012 09:26
Show Gist options
  • Save michalbcz/3634032 to your computer and use it in GitHub Desktop.
Save michalbcz/3634032 to your computer and use it in GitHub Desktop.
groovy - simple 'tree' command implementation
new File(".").eachDirRecurse { dir ->
/* if you wonder why not to write ~/\\/ directly see
http://groovy.codehaus.org/Strings+and+GString#StringsandGString-SlashyStringliterals or
http://jira.codehaus.org/browse/GROOVY-2451 */
def bs = "\\\\"
def fs = "/"
def pattern = ~/$bs|$fs/
/* ------------------------------- */
def numberOfDashes = dir.path.findAll(pattern).size()
println " " * numberOfDashes + " - " + dir.name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment