Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-28-2006, 08:33 PM   #1
LQ Newbie
Registered: Mar 2005
Posts: 4

Rep: Reputation: 0
Recursively traversing sub-directories

What I need to do is recursively traverse some sub-directories, and perform an operation on each file in that subdirectory. More specifically I need to run the specified command on each file and have the output put in the same directory. This is what I have so far:

find . -name *.class -exec jad {} \;

This works fine except that the ouput file that jad generates is put in the directory that I run the command from, whereas I need the output to be in the directory where the corresponding file resides. I would appreciate any help. Thanks in advance.
Old 01-29-2006, 12:00 AM   #2
Senior Member
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Ubuntu, FreeBSD
Posts: 1,449

Rep: Reputation: 48
find . -name *.class -execdir jad {} \;
Which does the same thing but only after changing to the directory the file is in.
Old 01-29-2006, 01:15 PM   #3
LQ Newbie
Registered: Mar 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks, that worked perfect. I have to do it on my mac instead of my gentoo box (different versions of find), but I got it to work.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove directories recursively with same name cboyd Linux - Newbie 5 01-14-2007 09:48 PM
How to Recursively Set Permissions for Directories Only edwin11 Linux - Software 4 12-30-2005 09:54 AM
List all files and recursively open directories. unreal128 Linux - General 2 07-16-2005 02:06 PM
Can ls recursively list only directories? Vosper Linux - General 3 07-16-2005 03:57 AM
tar, excluding directories recursively towlie Linux - Newbie 3 06-17-2004 12:32 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:02 PM.

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