Find the version number of all WordPress installations on your Linux server.

I have a lot of customers running WordPress on our shared hosting servers, and sometimes they neglect to update their WordPress installs. [Rolls Eyes]

I need to know which of these sites are using an obsolete version of WordPress so I may contact the customer and warn them that they need to update their software.

So here’s a helpful little Linux command I whipped up and ran as root to go through my /home folder searching for all WordPress versions. I only had to run it as root because I am checking through all users’ folders, not just my own. If you only want to check your own user, you don’t need root access.

I ran this command from my /home folder on the Linux server:

find . -name ‘version.php’ -exec grep ‘$wp_version =’ {} /dev/null \; > /tmp/wordpress-versions.log

Breakdown:

  • find . -name ‘version.php’
    Search through the current folder, recursively, for any file named version.php. This is where WordPress stores the WordPress version number.
  • -exec
    Execute a command with each found item.
  • grep ‘$wp_version =’ {}
    Look within the found version.php file(s) in a loop for the term $wp_version = and output the result.
  • /dev/null
    Trick grep into thinking there is a second file, forcing it to precede the output with the filename provided by find
  • \;
    Close the find command.
  • > /tmp/wordpress-versions.log
    Save the results to a log file in /tmp. You can tail -f this file while scanning, or simply open or cat it when you’re done. Leave this portion out of the command if you’d rather have it output directly to your screen.