How To Install flex on CentOS 7

In this tutorial we learn how to install flex on CentOS 7. flex is A tool for creating scanners (text pattern recognizers)

Introduction

In this tutorial we learn how to install flex on CentOS 7.

What is flex

The flex program generates scanners. Scanners are programs which can recognize lexical patterns in text. Flex takes pairs of regular expressions and C code as input and generates a C source file as output. The output file is compiled and linked with a library to produce an executable. The executable searches through its input for occurrences of the regular expressions. When a match is found, it executes the corresponding C code. Flex was designed to work with both Yacc and Bison, and is used by many programs as part of their build process. You should install flex if you are going to use your system for application development.

We can use yum or dnf to install flex on CentOS 7. In this tutorial we discuss both methods but you only need to choose one of method to install flex.

Install flex on CentOS 7 Using yum

Update yum database with yum using the following command.

sudo yum makecache

After updating yum database, We can install flex using yum by running the following command:

sudo yum -y install flex

Install flex on CentOS 7 Using dnf

If you don’t have dnf installed you can install DNF on CentOS 7 first. Update yum database with dnf using the following command.

sudo dnf makecache

After updating yum database, We can install flex using dnf by running the following command:

sudo dnf -y install flex

How To Uninstall flex on CentOS 7

To uninstall only the flex package we can use the following command:

sudo dnf remove flex

References

Summary

In this tutorial we learn how to install flex on CentOS 7 using yum and dnf.