1752583 Members
4362 Online
108788 Solutions
New Discussion юеВ

Find and perl

 
Leo The Cat
Regular Advisor

Find and perl

Hi

Here a find command

find /su01 -name "opatch.pl" 2>/dev/null
result is:
/su01/app/oracle/product/1010/OPatch/opatch.pl

How to execute the result with parameters like this:

perl "My Result from the find command" -lsinventory -detail

any idea ?

Bests Regards
Den
2 REPLIES 2
Ivan Ferreira
Honored Contributor

Re: Find and perl

You can use -exec, and {} will be replaced by the file found:

find /su01 -name "opatch.pl" -exec perl {} -lsinventory -detail \;

Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
James R. Ferguson
Acclaimed Contributor

Re: Find and perl

Hi Den:

If you have the interpreter shebang line defined (as you should), then using Ivan's syntax:

# find /su01 -name "opatch.pl" -exec {} -lsinventory -detail \;

...you will find that regardless of what the interpreter is, the file thus found will be executed.

You could also pre-test with:

# find /su01 -name "opatch.pl" -exec perl -c {} -lsinventory -detail \;

...which would perform a syntax compilation in Perl's case but not actually execute the file.

Regards!

...JRF...