Showing results for 
Search instead for 
Did you mean: 

Find and perl

Leo The Cat
Regular Advisor

Find and perl


Here a find command

find /su01 -name "" 2>/dev/null
result is:

How to execute the result with parameters like this:

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

any idea ?

Bests Regards
Ivan Ferreira
Honored Contributor

Re: Find and perl

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

find /su01 -name "" -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 "" -exec {} -lsinventory -detail \; 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 "" -exec perl -c {} -lsinventory -detail \;

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