1.3 Installing Bash
To follow this course and solve the exercises, you need to have access to a computer running BASH.
1.3.2 If you are on Windows
If you run Windows, you will need to install Bash. You have three options: 1. The recommended option is to use the Windows Subsystem for Linux (WSL) through the Ubuntu application. You can install it by following this tutorial. This is probably the best option for most. But note: This only works for Windows 10 or higher. 2. Alternatively, you may install a virtual Linux on your computer using Virtualbox as explained in this tutorial. This also works for older Windows versions, but is a bit more complicated. 4. You switch from Windows to Linux or set up a dual boot. That is a good option if you have been thinking about switching to Linux but would like to give it a try first. This is a more complicated process no covered here - but you may ask us for help if you intend to do that. 5. Finally, you may also follow this course by using an account on a Linux machine that you can log in to. If you have a cluster account, for instance, you may log into that from Windows as explained here.
1.3.3 If you use a Mac
If you have a Mac with OS X, you have the ZSH shell already installed. This shell is very similar to Bash and sufficient for the course. You can also easily switch from ZSH to Bash by typing chsh -s /bin/bash
into the terminal and confirming the change with your password. If you reopen the terminal now, the default shell will be Bash.
There are still differences between the Mac version of Bash and the one we’re teaching here (the GNU version available on all Linux machines). We’ve collected some differences here that might give you troubles when following this course. If you come across any issues during the course, consult the list below and follow the Mac-specific solution:
- Some useful commands such as
wget
are not installed on Mac by default. During the course, if you come across any program (or command) you’re still missing, you can use homebrew to install it. - Although
sed
exists on Mac, the syntax is slightly different. Use homebrew to installgsed
instead:brew install gnu-sed
. Once you’ve done that, replace anysed
command withgsed
. - Although
grep
exists on Mac, the syntax is slightly different. Use homebrew to installggrep
instead:brew install grep
. Once you’ve done that, replace anygrep
command withggrep
. - Instead of using
zcat file.gz
to print a zipped file, usegunzip -c file.gz
- Using
echo
on a string containing any exclamation points leads to an error. This can be prevented by using single quotes around the exclamation point:echo "Hello world"'!'
- The command
shuf
doesn’t exist on Mac. For our purposes here, you can replace it withsort -R
or use homebrew to installgshuf
instead:brew install coreutils
. Once you’ve done that, replace anyshuf
command withgshuf
.