LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-27-2006, 05:10 PM   #1
Banacek
LQ Newbie
 
Registered: Nov 2006
Posts: 5

Rep: Reputation: 0
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!
 
Old 11-27-2006, 05:20 PM   #2
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
try
find /path -name "*.bit"
 
Old 11-27-2006, 05:22 PM   #3
Banacek
LQ Newbie
 
Registered: Nov 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ygloo
try
find /path -name "*.bit"
No, that didn't work. Thanks though!
 
Old 11-27-2006, 05:29 PM   #4
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
here works...
try without "
find /path -name *.bit

Last edited by ygloo; 11-27-2006 at 05:30 PM.
 
Old 11-27-2006, 05:30 PM   #5
Banacek
LQ Newbie
 
Registered: Nov 2006
Posts: 5

Original Poster
Rep: Reputation: 0
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.
 
Old 11-27-2006, 05:33 PM   #6
Banacek
LQ Newbie
 
Registered: Nov 2006
Posts: 5

Original Poster
Rep: Reputation: 0
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.
 
Old 11-27-2006, 05:39 PM   #7
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
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
 
Old 11-27-2006, 05:43 PM   #8
Banacek
LQ Newbie
 
Registered: Nov 2006
Posts: 5

Original Poster
Rep: Reputation: 0
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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict exe files inside an archive files in samba paulreynand Linux - Networking 2 02-02-2006 04:07 AM
List all files and recursively open directories. unreal128 Linux - General 2 07-16-2005 02:06 PM
only 2 directories are formed inside lib/mod even after config 3 kernels ramya272 Linux - Newbie 1 02-26-2004 11:13 AM
Asking LS for a list of directories only gary knott Linux - Newbie 1 11-12-2003 05:49 PM
list of directories greg108 Linux - Newbie 5 08-08-2003 03:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration