I want to delete all index.php files, in all directories and sub-directories file that had this specific expression on it’s code
if ( !class_exists( 'WPPluginsOptions' ) )
can we do this in ssh using Linux command or whatever
Advertisement
Answer
- Find all files named
index.phpusing the linuxfindcommand. - Search in the files for the string
if ( !class_exists( 'WPPluginsOptions' ) )using the linuxgrepcommand with the-lflag. (Only output files that match what you are looking for ) - Use the linux
xargscommand to send the list of files from the grep command to the linuxrmcommand.
All together.
find -L /var/www -iname "index.php" -exec egrep -l 'if ( !class_exists( '"'"'WPPluginsOptions'"'"' ) )' {} + | xargs rm -f
Be careful with this command because it doesn’t ask you before deleting files. You should test it in a safe place before running it in production.