LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-17-2007, 03:29 AM   #1
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Rep: Reputation: 16
List all folders containg headers


How can I list all folders containing headers (*.h)?
I would like to list each folder only once.
 
Old 04-17-2007, 04:08 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

This should work:

find . -name "*.h" -exec dirname {} \; | sort -u

Hope this helps.
 
Old 04-17-2007, 04:36 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you are looking for files indexed by updatedb, you could also use locate:
locate --regex '.*\.h$' | sed 's#\(.*\)/[^/]*#\1#' | uniq
 
Old 04-17-2007, 05:55 AM   #4
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Original Poster
Rep: Reputation: 16
Thank you very much.
Now I even learned a lot of new stuff in only 2 command lines:
-exec
dirname
sort -u
--regex
uniq
 
  


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
can't list some winxp documents and settings folders gSalsero Linux - Networking 2 03-01-2007 10:53 AM
Samba can create new files and folders but access denied in any new folders k.king Linux - Networking 2 01-15-2006 06:14 AM
Error reading CDs containg audio and data tracks A_Thom Linux - Hardware 0 11-13-2004 08:11 PM
sed not working if value is passed thru a variable containg value suchi_s Programming 7 10-29-2004 07:41 AM
Where can find the file containg the information of the printer driver Naveen Sriram Linux - Software 1 09-24-2004 05:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:08 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