perl script to find all files with certain extensions
Posted on 2010-08-23
I am trying to write a perl script which finds all files on a server excluding certain directories and only including certain file types..
I have the following command.
find /opt/lampp/htdocs/ -name '*' -path '/opt/lampp/htdocs/some/folder' -prune -o -path '/opt/lampp/htdocs/another/folder' -prune -o -print;
This works fine and returns all files on the server.
I have two issues.
1. This runs fine from the console... but when run from inside my perl script I get the following error.
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
2. I need to only return files with certain extensions, this includes .pl, .txt, .php, .html, .xml, .js . I know I could run multiple commands using '*.php" but can this be incorporated into a single command?