LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-03-2007, 03:40 AM   #1
xeon123
Member
 
Registered: Sep 2006
Posts: 364

Rep: Reputation: 16
list recursively files with for


Hi,

i want to build a bash script that do the following:

for each java file found recursively in directory structure of n-layers
execute a command.

Thanks,
Pedro
 
Old 04-03-2007, 04:36 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
what's the command you want to execute. normally, using find will do what you want
Code:
find /dir -type f -name "*.java" -exec "somecommand" {} \;
or this syntax
Code:
find /dir -type f -name "*.java" -print | xargs "somecommand"
 
Old 04-03-2007, 04:49 AM   #3
xeon123
Member
 
Registered: Sep 2006
Posts: 364

Original Poster
Rep: Reputation: 16
And, what bash script should i write to build the following:

for each java file found recursively in directory structure of n-layers
execute a command for that file.

Sorry, but i'm a newbie in bash.

Thanks.
 
Old 04-03-2007, 05:01 AM   #4
xeon123
Member
 
Registered: Sep 2006
Posts: 364

Original Poster
Rep: Reputation: 16
I've tried to execute this command:

Code:
 find . -type f -name "*.java" -print -exec 'cleartool.exe mklabel LABEL' {} \;
and what i've got is:
Quote:
find: cleartool.exe mklabel MDCS36_Core: No such file or directory
Since i'm a newbie in bash, i don't know how to solve this problem. I suppose that, the filename isn't passed to the cleartool command, but i dpn't know how to solve it.

Can you help me?

Thanks,
Pedro
 
Old 04-03-2007, 10:45 AM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,426

Rep: Reputation: 821Reputation: 821Reputation: 821Reputation: 821Reputation: 821Reputation: 821Reputation: 821
The quotes make bash think 'cleartool.exe mklabel LABEL' is one big command name. The {} should be in quotes:

Code:
 find . -type f -name "*.java" -print -exec cleartool.exe mklabel LABEL '{}' \;
 
Old 04-04-2007, 07:06 AM   #6
xeon123
Member
 
Registered: Sep 2006
Posts: 364

Original Poster
Rep: Reputation: 16
Thank you.

Sorry for my ingnorance in bash scripts.
 
Old 04-04-2007, 03:38 PM   #7
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,426

Rep: Reputation: 821Reputation: 821Reputation: 821Reputation: 821Reputation: 821Reputation: 821Reputation: 821
You don't need to apologise, no one is born knowing about shell scripting
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursively move files michaelsanford Linux - General 4 10-02-2005 01:50 PM
Copying hidden files recursively? mrd Linux - General 1 09-30-2005 07:51 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
how to rm backup files recursively wazoo Linux - Newbie 6 12-31-2004 10:03 AM


All times are GMT -5. The time now is 05:58 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration