Computing.Net > Forums > Unix > Find file & execute command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Find file & execute command

Reply to Message Icon

Name: hamim
Date: December 13, 2004 at 01:51:45 Pacific
OS: Sco Openserver
CPU/Ram: 2 gig/2
Comment:

Hi
I would like to run a command that goes to each sub directory on a file system.It 1st has to search through each directory & execute the command.
I tried this but no luck:
find . -type f filename -print |while read eg
do
prostrct list automate $eg
done

PS: "prostrct list automate" is an external programme run by progress application



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: December 13, 2004 at 09:37:00 Pacific
Reply:

Why don't you search for each directory:

# untested
find . -type d -print: while read eg
do
cd $eg
.
.
done


0

Response Number 2
Name: Dlonra
Date: December 13, 2004 at 16:34:43 Pacific
Reply:

find . -type f -exec prostrct list automate {} \;


0

Response Number 3
Name: hamim
Date: December 14, 2004 at 06:25:31 Pacific
Reply:


Sorry ,but I forgot to metion that it has to cd into each directory and execute the command:
prostrct list automate

eg:
./unitrans/vw/automate.st
./unitrans/toyota/automate.s
./bmi/automate.st
./amh/automate.st
./nissan/automate.st


0

Response Number 4
Name: Dlonra
Date: December 14, 2004 at 13:50:35 Pacific
Reply:

Your original
"find . -type f filename -print " is an erroneous find command.

If you want to:
find all files named "automate.st" (assume 1 per directory)
cd to the directory containing the file
execute command "do.this" on the file
then
for f in $(find . -type f -name automate.st);do
cd $(dirname $f);do.this automate.st;cd -;done


0

Response Number 5
Name: hamim
Date: December 15, 2004 at 01:19:35 Pacific
Reply:

Hi

Thanks alot for your help -it works great
Cheers!!!!


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Find file & execute command

how to find files and move to direc www.computing.net/answers/unix/how-to-find-files-and-move-to-direc/4822.html

find files www.computing.net/answers/unix/find-files/3391.html

Shell script to find files www.computing.net/answers/unix/shell-script-to-find-files/5440.html