http://www.perlmonks.org?node_id=1050343

I just had occasion to type this and thought I'd share (fairly sure someone will have done this before, but my search-fu fails me).
ls -R | perl -ne 'if(/:$/){s/:$//;s/[^\/]*\//--/g;s/^-/\t|/;print}'
Result:
$ ls -R | perl -ne 'if(/:$/){s/:$//;s/[^\/]*\//--/g;s/^-/\t|/;print}' |---branches |---hooks |---info |---logs |-----refs |-------heads |-------remotes |---------origin |---objects |-----02 |-----0a |-----10 |-----24 |-----27 |-----3f |-----41 |-----4e |-----64 |-----69 |-----6e |-----70 |-----74 |-----76 |-----7b |-----82 |-----8d |-----94 |-----a7 |-----ac |-----b0 |-----b7 |-----d6 |-----dd |-----e2 |-----info |-----pack |---refs |-----heads |-----remotes |-------origin |-----tags |-Spider |---Muffet |-----Filter |-------Reader |-----Output |-------Writer


Replies are listed 'Best First'.
Re: One liner to print a file system tree on UNIX like systems
by toolic (Bishop) on Aug 21, 2013 at 13:35 UTC
    Golf! Fewer strokes...
    ls -R | perl -ne'if(s/:$//){s{[^/]*/}{--}g;s/^-/\t|/;print}'

    Or just tree -d

Re: One liner to print a file system tree on UNIX like systems
by goldenblue (Acolyte) on Oct 02, 2013 at 19:17 UTC
    That's actually pretty nice!

    --
    the singularity will happen.