The following script displays a useful tree structure of a directory; it’s similar the old DOS-command:
find . -type d | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/" | tee output_.txt
As noted, three parts are combined:
find: This command searches the directory tree rooted at each given file name by evaluating the given expression from left to right, according to the rules of precedence, until the outcome is known (the left hand side is false for and operations, true for or), at which point find moves on to the next file name.
sed: (s)tream (ed)itor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed’s ability to filter text in a pipeline which particularly distinguishes it from other types of editors. See ‘sed –help’ for usage information.
tee: The command reads standard input, then writes its content to standard output. It simultaneously copies the result into the specified file(s) or variables.
cd myDirectory/ find . -type d | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/" | tee output_.txt
|-B.B. King | |-Kansas City 1972 |-Bob Forrest | |-Modern folk and blues |-Eric Clapton | |-MTV Unplugged | |-Old Sock | |-On the crossroad | |-Wynton Marsalis & Eric Clapton Play The Blues |-Eric Gales Band | |-The Psychedelic Underground |-Eric Johnson | |-Acoustic Bootleg | |-Venus Isle |-J.J. Cale & Eric Clapton | |-The Road to Escondido |-James Brown | |-At Studio 54 |-Jeff Beck | |-Emotion And Commotion |-Jimi Hendrix | |-Are You Experienced | |-Axis Bold as Love | |-Band of Gypsys | |-BBC Sessions | |-Electric Ladyland | |-Experience Hendrix- The Best of Jimi Hendrix | |-The Early Years |-Jimi Hendrix & Stephen Stills | |-At Stills Basement |-John Mayall | |-Blues From Laurel Canyon | |-Life In The Jungle |-Johnny Cash | |-American Recordings | |-Unchained |-Muddy Waters | |-They Call Me Muddy Waters |-Robert Johnson | |-Genius Of The Blues |-Steve Ray Vaughan | |-albert king & steve ray vaughan | |-Live at Pier | |-texas flood |-Stevie Ray Vaughan & Jeff Beck | |-The Fire Meets The Fury |-The Yardbirds | |-Blue Eyed Blues
find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' | tee output_.txt