The Mijingo Blog

Latest news, updates, free tutorials, and more from Mijingo.

Bash Alias to Download and Extract Latest WordPress

by Ryan Irelan

In the last blog post we covered the basics of bash aliases and how to create one. This time I want to jump back into Greg’s Command Line Fundamentals course and share a nice trick on how to automate downloading and extracting the latest version of WordPress.

This is an alias we could use just about every single day.

I have an empty directory on my computer called new-wp. I want to create an alias that will:

  1. Download the latest WordPress via wget
  2. Unarchive the download using tar
  3. Clean up by deleting the downloaded archive.

Here’s what the alias would look like:

alias get_wp="wget && tar zxvf latest.tar.gz && rm latest.tar.gz"

The first part is using the alias keyword to start defining a new alias, followed by the name of the alias. In this example we’ll call it get_wp.

Then we define the commands, starting with wget, fetching the latest.tar.gz file on the WordPress server, which always contains the latest version of the software.

We use the && operator to tell Bash to run an additional command (but only when/if the first one completes). The second command is to unarchive the file using tar.

Finally, we add another && operator to remove and bash the downloaded archive. Since we’ve already unarchived it, we no longer need it around.

Now run the command inside the new-wp directory


and see the magic happen!

If you prefer to watch instead of read, check out this excerpt of the same tutorial from Greg Aker’s Command Line Fundamentals course:

Filed Under: Command Line, Free Tutorials