Re: find / grep to list files with php's short_open_tag
Am 10.05.2013 01:52, schrieb David Beveridge: >> [egreshko@meimei try]$ find /tmp/try -type f -name \*.php -exec grep -l -i >> -n -G "> /tmp/try/one.php >> >> The only thing worse than a poorly asked question is a cryptic answer. >> > So you want all the > grep -r " "<\?xml" | grep -v "<\?=" i finally solved it with a php-script itself using a years ago written PHP-SPL-wrapper for recursive listing of files started in the dir the php-cli-script is living relevant is " because this short echo-variant is starting with PHP 5.4 always supported and no longer in context with "short_open_tag" from php.ini well, i found 7 files out of some thousand written in the last 10 years :-) script and 3 test-files below __ #!/usr/bin/php ListFilesRecursive(/**$path*/__DIR__, /**$details*/false, /**$excludes*/array()); foreach($liste as $file) { if($file != __FILE__ && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php' && is_readable($file)) { $content = file_get_contents($file); if(strpos($content, ' __ $fs->ListFilesRecursive() is basically this: $spl_objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); try { foreach($spl_objects as $filename=>$spl_object) { if(!$spl_object->isDir()) { if(DIRECTORY_SEPARATOR === "\\") { $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); } if(substr($filename, 0, 2) === './') { $filename = substr($filename, 2); } if(empty($pattern) || !preg_match($pattern, $filename)) { if(!$ignore_svn || strpos($filename, '/.svn') === false) { $enumerate_list[] = $filename; } } } } } catch(UnexpectedValueException $e) { error_log('Directory "' . $path . '" contained a directory we can not recurse into'); return false; } sort($enumerate_list); __ [harry@srv-rhsoft:/www]$ cat test-short-open-1.php __ [harry@srv-rhsoft:/www]$ cat test-short-open-2.php "> __ [harry@srv-rhsoft:/www]$ cat test-short-open-3.php __ signature.asc Description: OpenPGP digital signature -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Re: find / grep to list files with php's short_open_tag
Hi Reindl, On Thu, May 09, 2013 at 03:05:01PM +0200, Reindl Harald wrote: > > because it does not work and i have no idea how to "mask" the LF for grep > > [harry@srv-rhsoft:~]$ find /mnt/data/www/ -type f -name \*.php -exec grep -l > -i -n -F "http://mid.gmane.org/20130509123904.gc6...@kuru.dyndns-at-home.com> Hope this helps, -- Suvayu Open source is the future. It sets us free. -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Re: find / grep to list files with php's short_open_tag
> > [egreshko@meimei try]$ find /tmp/try -type f -name \*.php -exec grep -l -i -n > -G " /tmp/try/one.php > > -- > The only thing worse than a poorly asked question is a cryptic answer. > > So you want all the https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Re: find / grep to list files with php's short_open_tag
On 05/09/13 21:05, Reindl Harald wrote: > > Am 09.05.2013 05:53, schrieb Patrick O'Callaghan: >> On Tue, 2013-05-07 at 19:41 +0200, Reindl Harald wrote: >>> find /data/www/ -type f -name \*.php -exec grep -l -i -n -F ">> lists any file which contains ">> >>> find /data/www/ -type f -name \*.php -exec grep -l -i -n -F ">> is expected to find any file with ">> but that does not work and if someone finds google empty it was me :-( >> Not sure if "\n" is allowed, but why not use $ for end of line as in >> most regular expressions? > because it does not work and i have no idea how to "mask" the LF for grep > > [harry@srv-rhsoft:~]$ find /mnt/data/www/ -type f -name \*.php -exec grep -l > -i -n -F " [harry@srv-rhsoft:~]$ > > as you see nothing found > > [harry@srv-rhsoft:~]$ cat /mnt/data/www/short-open.php > echo 'TEST'; > ?> > > as you see there is at least one file > -G seems to work Got a splitting headache, so not thinking of the implications [egreshko@meimei try]$ cat one.php [egreshko@meimei try]$ cat two.php [egreshko@meimei try]$ find /tmp/try -type f -name \*.php -exec grep -l -i -n -G " signature.asc Description: OpenPGP digital signature -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Re: find / grep to list files with php's short_open_tag
Am 09.05.2013 05:53, schrieb Patrick O'Callaghan: > On Tue, 2013-05-07 at 19:41 +0200, Reindl Harald wrote: >> find /data/www/ -type f -name \*.php -exec grep -l -i -n -F "> lists any file which contains "> >> find /data/www/ -type f -name \*.php -exec grep -l -i -n -F "> is expected to find any file with "> but that does not work and if someone finds google empty it was me :-( > > Not sure if "\n" is allowed, but why not use $ for end of line as in > most regular expressions? because it does not work and i have no idea how to "mask" the LF for grep [harry@srv-rhsoft:~]$ find /mnt/data/www/ -type f -name \*.php -exec grep -l -i -n -F " as you see there is at least one file signature.asc Description: OpenPGP digital signature -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Re: find / grep to list files with php's short_open_tag
On Wed, May 08, 2013 at 11:23:34PM -0430, Patrick O'Callaghan wrote: > On Tue, 2013-05-07 at 19:41 +0200, Reindl Harald wrote: > > find /data/www/ -type f -name \*.php -exec grep -l -i -n -F " > is expected to find any file with " > but that does not work and if someone finds google empty it was me :-( > > Not sure if "\n" is allowed, but why not use $ for end of line as in > most regular expressions? Reindl is using fgrep (implied by the -F flag), so I would think \n is interpreted literally. I would agree with your suggestion to use $ grep -E "https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Re: find / grep to list files with php's short_open_tag
On Tue, 2013-05-07 at 19:41 +0200, Reindl Harald wrote: > am i stupid or grep? :-) Well I know you aren't grep ... > find /data/www/ -type f -name \*.php -exec grep -l -i -n -F " lists any file which contains " > find /data/www/ -type f -name \*.php -exec grep -l -i -n -F " is expected to find any file with " but that does not work and if someone finds google empty it was me :-( Not sure if "\n" is allowed, but why not use $ for end of line as in most regular expressions? poc -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org