LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-22-2011, 01:13 PM   #1
disruptive
Member
 
Registered: Dec 2005
Posts: 76

Rep: Reputation: 15
getting directing with find -name


I'm using this:

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

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

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

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

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

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

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


Reply


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 10:20 AM
Directing a domain to a port? Zeno McDohl Linux - Server 1 12-09-2008 04:03 PM
Directing audio into ffmpeg Aylesworth Linux - General 2 07-13-2006 09:12 PM
Re-directing e-mail rigel_kent Linux - General 3 06-09-2006 02:07 PM
spamassassin (directing email). stomach Linux - Software 5 02-17-2006 06:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:11 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration