Basic Regular Expressions: Working with Hardware Data

30 minutes
  • 2 Learning Objectives

About this Hands-on Lab

Regular expressions allow us to take the most complicated pieces of text and match the patterns within them for a variety of results, but to learn regular expressions we have to start somewhere. Using a combination of literals, digits, and word characters, alongside some basic text processing commands (such as `grep`), we can match product IDs and architectures and parse down a large product list into something more manageable.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Parse and save CPU data.

Use a regular expression to parse through the intel-cpus.cvs file. Save the results as intel-options.csv.

Parse and save GPU data.

Use a regular expression to parse through the gpus.cvs file. Save the results as gpu-options.csv.

Additional Resources

You work for Ethercloud, a web hosting company. Ethercloud keeps their own servers, and the time has come for an upgrade in hardware. Two CSV files have been provided to you: One features a list of current Intel CPUs and another of GPUs.

It has been requested that you parse down the list so that only the desired options are included for the CPU list, then for the GPU list. You know that the architecture required all follows the same basic pattern, as provided by the examples below. Using whatever tools you desire (such as grep), generate a new file comprised only on CPUs matching the appropriate product IP, then create another list of GPUs.

Intel CPUs

The CPU list can be found in the cloud_user home directory, as intel-cpus.csv. Save the parsed down file as intel-options.csv.

Your regex should match the following sample product IDs:



A GPU list can be found in the cloud_user's home directory, as gpus.csv. Save the parsed down file as gpu-options.cvs.

Your regex should match the following sample architectures:


Note that there is more than one correct method to complete this learning activity and more than one correct regular expression.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?