Mornin' --

By using back-ticks, you are running the find command in a sub-shell.  The
usual Shell continuation conventions apply.  You have to escape the
new-line:

     `find $dir_to_search
                -name cache -prune          \<nl>
                -o -name tmp -prune          \<nl>
                -o -name session -prune   \<nl>
                -o -print`;

Note: There can be no space between the escape and the new-line character.
Note: Perl provides a find() command so you don't have to shell-out and
confuse the issue


On Thu, Jan 1, 2015 at 1:19 PM, SSC_perl <p...@surfshopcart.com> wrote:

>         Is it possible to wrap a `find` command on multiple lines in a
> script?  This is what I'm using now:
>
> foreach $dir_to_search (@dirs_to_search) {
>         $dir_count--;
>         @files = map {
>                 s|/home/user/public_html ||;
>                 $_;
>         } `find $dir_to_search -name cache -prune -o -name tmp -prune -o
> -name session -prune -o -print`;
>
>         I'd like to be able to do something like this to make it more
> readable:
>
> foreach $dir_to_search (@dirs_to_search) {
>         $dir_count--;
>         @files = map {
>                 s|/home/user/public_html||;
>                 $_;
>         } `find $dir_to_search
>                 -name cache -prune
>                 -o -name tmp -prune
>                 -o -name session -prune
>                 -o -print`;
>
> however my searches have turned up nothing.  Using returns, commas,
> backslashes, or concatenation breaks the find.  Does anyone know if this is
> doable?
>
> Thanks,
> Frank
> SurfShopCART
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 

Bob Goolsby
bob.gool...@gmail.com

Reply via email to