Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 02-22-2011, 12:13 PM   #1
Registered: Dec 2005
Posts: 76

Rep: Reputation: 15
getting directing with find -name

I'm using this:

find -name, but I want the directory that the file is within. How best to do this with the find command?

Old 02-22-2011, 12:15 PM   #2
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 673

Rep: Reputation: 94
how about -exec dirname {} \;
Old 02-22-2011, 12:35 PM   #3
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,330

Rep: Reputation: 254Reputation: 254Reputation: 254
find -name -printf '%h\n'
man find shows even more options.
Old 02-22-2011, 12:37 PM   #4
Senior Member
Registered: Jan 2010
Posts: 1,629

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Originally Posted by disruptive View Post
I'm using this:

find -name, but I want the directory that the file is within. How best to do this with the find command?

How about using -printf option to customize the output:
find . -name -printf '%h\n'
Have a look at the man-page (search for -printf) to get more options on how to format the output.
Reuti was faster.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Domain re-directing using DNS ZAMO Linux - Server 1 07-21-2010 09:20 AM
Directing a domain to a port? Zeno McDohl Linux - Server 1 12-09-2008 03:03 PM
Directing audio into ffmpeg Aylesworth Linux - General 2 07-13-2006 08:12 PM
Re-directing e-mail rigel_kent Linux - General 3 06-09-2006 01:07 PM
spamassassin (directing email). stomach Linux - Software 5 02-17-2006 05:59 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:57 AM.

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