Can someone who is familiar with shell commands tell me how to obtain a list of a directory and its subdirectories down to depth n (and at best while EXcluding files; I’m interested only in the directory structure).
Concretely, I want to get an overview of my music library folder. It’s general structure is /Music library/<artist name>/<album name>/<title name.mp3>, and I’d like to print out a list of the folders it contains.
You got the exact answer you asked for, but why the max depth? The whole music library only has directories two levels down as you say yourself, so output with or without the -maxdepth will be the same.
BTW studying the possibilities of man find will give you a wealth of methods to do things like this.
Because the music library has 3 levels, and if I print out everything down to the very last, I end up with endless pages of title names, which I don’t need at all.
Filtering the result to get rid of file names prolly would’ve been another option, and I experimented with it a bit, but it didn’t work the way I wanted it to.
Frankly, I hate MAN pages. More complex commands like find have descriptions that are rather long and fantastically tedious to read. A lot of commands have rather nice explanations on the internet, but it’s difficult to google for ‘find’ given the widespread use of the word.
Though I am sure you got the point, I will nevertheless protest (staying nasty >:) ). You third level (the title names) are files (mp3) and not directories. Thus the *-type d *is the crucial option to your quest, not the -maxdepth 2.
I’m not sure I got the point, but I’ll definitely look into the issue. Could you please type up and executive summary and leave 2 copies with my secretary? Oh, and another copy goes to Mr. Barnes in accounting.
Not so young any more. But my thanks are sincere! I certainly will try to switch over to your method. The more because I mostly type man tool instead of man:tool in the title bar, which gives me an error window I have to click and a click back to the title bar and typing to correct. So the gain is in practice much more to me old fellow.