Video Coming Soon...

Created by Zed A. Shaw Updated 2024-10-08 04:45:56

01: Gearing Up

In this exercise you'll either find or install the software you need to complete the course. You don't need much, just a Terminal, Text Editor, and two programs named grep and sed.

macOS/OSX

You'll be using the command line (Terminal) in this course, but not very much. Most of the commands will be explained to you and demonstrated, but I may create a free command line crash course if enough people need it.

Linux

On Linux you should be able to follow the same setup as macOS. You'll need the following:

The version of sed and grep won't matter much since we'll be using only the most basic features.

Windows

For windows you have two choices:

  1. Use my automated install that will install many tools that I use in all of my courses.
  2. Manually install the software you need.

I'll cover the automatic process first since it'll install many useful things, but if you are paranoid about what is installed then just do it manually.

Automatic Windows Setup

WARNING It's better for you to create a special Administrator user, switch to that user, then remove admin privileges from your main user account. This will create a personal account and an admin account, which increases your security. Research has shown that running around the internet as Administrator is incredibly stupid. If you simply run as a regular user than you'll effectively stop about 80% of potential attack vectors, and it's not much of an inconvenience. Windows will prompt you for the admin user's password whenever you need admin rights.

Open a PowerShell (NOT PowerShell ISE) window and paste in these two commands one at a time:

irm https://learncodethehardway.com/setup/base.ps1 -outfile base.ps1
powershell -executionpolicy bypass .\base.ps1

Be sure that you stay at your keyboard and answer all the questions to install. Once these commands finish you can use winget to install ugrep and sed:

winget install Genivia.ugrep
winget install mbuilov.sed

If everything worked then you should be able to start Terminal by hitting the win key and typing "terminal" into the start menu. You can also start Geany the same way but type "geany."

After this you can test your installation by typing these two commands into Terminal (which is just running PowerShell in a nicer window):

ugrep --version
sed --version

Keep in mind that you'll type the command ugrep every time you see me type grep, but it'll work the same after that.

Manual Windows Setup

This could also be called "The Minimalist Setup." You'll want to install the following:

You can also install the tool winget and then install each of these quickly with these commands:

winget install Microsoft.WindowsTerminal
winget install Geany.Geany
winget install Genivia.ugrep
winget install mbuilov.sed

Once these are installed you're done. You can test your install by starting a new Terminal and typing these two commands:

ugrep --version
sed --version

Also remember that when you I say you need to type grep you should type ugrep to run the version you installed.

Quick grep Intro

Before we conclude this exercise I'll give you a quick introduction to running grep (ugrep on Windows). This will confirm that you're ready to continue with the rest of the exercises.

First the way to think about the command line is that you're talking to the computer inside the Terminal. When you type a command, it is a sequence of words, each separated by spaces. When you typed grep --version you were telling the Terminal (also called your "shell") to do this:

  1. Find the program named grep (ugrep on Windows).
  2. Run it but give it the extra argument --version.
  3. Your OS (Windows, Linux, macOS) starts the program, and tells it the argument --version.
  4. An "argument" is just an option, kind of like adding an adjective to a word like adding "big" to "cake." Or, like checking different checkboxes off in the options of a video game.
  5. The program runs, changes its behavior based on your argument, and in this case prints out its version information.

The most important thing to understand is that this will not work:

grep--version

If you're on windows then this will NOT work also:

ugrep--version

There needs to be a space between the word grep and the argument --version. Try typing this incorrect command so you can see what the error is.

Once you have a grasp on this, you can move on to the next exercise.

Further Study

  1. Type grep --help (ugrep --help) to see the help options. These are probably way over your head, but it's always good to try things and see what you get.
  2. Be careful with the commands rm and del. If you type them even slightly wrong you'll accidentally delete all your files. Just avoid them until you're more confident with your skills, and start making backups of your computer now just in case.
Previous Lesson Next Lesson

Register for Learn Regex the Hard Way

Register to gain access to additional videos which demonstrate each exercise. Videos are priced to cover the cost of hosting.