Updating WordPress using a bash script

If you have shell access to your webserver this script can be used to upgrade your WordPress installation to the latest version quickly. Always remeber to backup your database and installation files before running it!

Do change the bold text to reflect your WordPress Internet address before you run the script.

#!/bin/bash
CURDIR=$(pwd)
SITE="http://yoursite.com/wordpress"
echo Updating WordPress located in $CURDIR
echo 1. Downloading latest WordPress install file.
wget -q http://wordpress.org/latest.tar.gz
echo 2.  Unpacking downloaded file.
tar zxf latest.tar.gz
cd wordpress/
echo 3.  Replacing old files with the unpacked ones.
tar cf - . | (cd $CURDIR; tar xf -)
echo 4.  Update the WordPress installation.
wget -q -O - ${SITE}/wp-admin/upgrade.php?step=1> /dev/null
echo 5.  Removing the WordPress file downloaded recently.
rm -f ../latest.tar.gz
echo 6.  WordPress is now upgraded.