in reply to Re: Running find.exe for multiple extensions
in thread Running find.exe for multiple extensions

Ya,I would also,but the thing is I need to grep for a variable,say $x in the resulting find.I am not able to combine both find and grep.Can you pls advise?

These are my needs 1.Find all .h,.c,.sh and put in an array 2. Grep for $x for each array member(from above find list)and put in an array

  • Comment on Re^2: Running find.exe for multiple extensions

Replies are listed 'Best First'.
Re^3: Running find.exe for multiple extensions
by wind (Priest) on Apr 29, 2011 at 23:21 UTC

    Any logic you can do in a shell, you can do using pure perl as well.

    I don't know what $x is, but there's no reason why you can't test against a mysterious $x variable as well.

    use File::Find; use strict; use warnings; my $x = shift; my @array; find(sub { push @array, $File::Find::name if /\.(?:h|c|sh)$/; }, '.'); my @x_files = grep {/\Q$x\E/} @array;