LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Find question (https://www.linuxquestions.org/questions/linux-newbie-8/find-question-297526/)

facets 03-04-2005 05:24 AM

Find question
 
Hi,

I need to find the last directory in a bunch of directories but can't work out how to do it. There is no exact structure so here's a rough example.

/home/dir1/movies
/home/dir2/music/jazz
/home/dir2/music/house
/home/dir3/apps/linux/cad
/home/dir3/apps/linux/graphcs

So with the example, i would like /home/dir2/music/jazz int he list but not /home/dir2/music same goes for /home/dir3/apps/linux/cad not /home/dir3/apps/linux.

I've tried -maxdepth and -mindepth but to no avail.

Any help would be rad.

cheers, William

nutthick 03-04-2005 06:54 AM

Sounds like you need some sort or recursive script to dig into the directories. What would be the last directory for

/home/dir3/apps/linux/cad
/home/dir3/apps/linux/graphcs

cad, graphcs or both?

facets 03-04-2005 06:57 AM

thanks for the reply.

the -prune flag helped here..

find -mindepth 4 -prune -type d

cheers! mark.

snip...

./Stuff/Music/[313 Crewz]/dj3000 - red line ep
./Stuff/Music/[313 Crewz]/Midnight Sound
./Stuff/Music/[313 Crewz]/[LH 004] Los Hermanos - Influence
./Stuff/Music/[313 Crewz]/inner elements[rs 94 038 cd]
./Stuff/Music/German Crewz/rs-06
./Stuff/Music/German Crewz/burnt friedman & jaki liebezeit - secret rhythms
./Stuff/Music/German Crewz/[GIGOLO 99] Dopplereffekt - Linear accelerator

nutthick 03-04-2005 07:04 AM

When you do that on

/home/dir3/apps/linux/cad
/home/dir3/apps/linux/graphcs

doesn't that bring up

/home/dir3/apps/linux
/home/dir3/apps/linux/cad
/home/dir3/apps/linux/graphcs

also would that work for

/home/dir1
/home/dir2
/home/dir3

Just a thought. If you've solved it great ;)


All times are GMT -5. The time now is 07:27 AM.