Hi Gurus,
I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the following error when run from perl script.
Thanks for your response. I tried using system ("find <Source-dir-path> ! \( -name '.html' -o -name '.xml' -o -name '.jsp' -o -name '.shtml' -o -name '.htaccess' \) -type f -print"); but that reported the same syntax error. I noticed that perl was eliminating the '\', so to get over the issue I used '\\' like indicated below and it worked like charm
`find <Source-dir-path> ! \\( -name '.html' -o -name '.xml' -o -name '.jsp' -o -name '.shtml' -o -name '.htaccess' \\) -type f -print`;
Perl has a module used for this purpose File::Find which should be more efficient than shelling out to the find command. It is also easy enough to code if you don't need to search sub directories
opendir (DIR,'path/to/folder') or die "$!";
my @files = grep {-f "path/to/folfer/$_" && !/\.html$|\.xml$|\.jsp$|\.shtml$|\.htaccess$/} readdir DIR;
close DIR;
print "$_\n" for @files;
source isn't a system command, but a shell-internal, telling it to read the given script in the current shells context. To check this, at the command prompt enter
$ which source
$ type source
$ type .
If you get anything but "is a shell builtin" or "not found", I'd be very surprised.