LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Getting a list of directories with certain files inside... (https://www.linuxquestions.org/questions/linux-newbie-8/getting-a-list-of-directories-with-certain-files-inside-505349/)

Banacek 11-27-2006 05:10 PM

Getting a list of directories with certain files inside...
 
Hello, I'm new to linux, and I am trying to get a list of directories that contain files with a certain extention. So far I have:

find | grep -i *bit$

but this gives me all the files. What is the best way to just get a list of directories that contains .bit files? Thanks!

ygloo 11-27-2006 05:20 PM

try
find /path -name "*.bit"

Banacek 11-27-2006 05:22 PM

Quote:

Originally Posted by ygloo
try
find /path -name "*.bit"

No, that didn't work. Thanks though!

ygloo 11-27-2006 05:29 PM

here works...
try without "
find /path -name *.bit

Banacek 11-27-2006 05:30 PM

Ok, so this:

find -name \*.bit -printf %h\\n

gives me all the directories, but it repeats directory names. Now I just need to trim it down to no repeat directories.

Banacek 11-27-2006 05:33 PM

Quote:

Originally Posted by ygloo
here works...
try without "
find /path -name *.bit

It says "find: No match." and I know that's not true. The .bit files are contained in multiple different subdirectories, if that helps.

nx5000 11-27-2006 05:39 PM

If you want to remove duplicates, go with:
command | sort | uniq

The other command given by somebody else works though, replace path by the real path and don't forget about the " otherwise the shell will happily replace it before running the find which would result in no matches

Banacek 11-27-2006 05:43 PM

Quote:

Originally Posted by nx5000
If you want to remove duplicates, go with:
command | sort | uniq

The other command given by somebody else works though, replace path by the real path and don't forget about the " otherwise the shell will happily replace it before running the find which would result in no matches

I was just about to post that:

find -name \*.bit -printf %h\\n | uniq

works. I will try the other command as well, with the real path. Thanks!


All times are GMT -5. The time now is 10:34 PM.