English 中文(简体)
AWK - Environment
  • 时间:2024-12-22

AWK - Environment


Previous Page Next Page  

This chapter describes how to set up the AWK environment on your GNU/Linux system.

Installation Using Package Manager

Generally, AWK is available by default on most GNU/Linux distributions. You can use which command to check whether it is present on your system or not. In case you don’t have AWK, then install it on Debian based GNU/Linux using Advance Package Tool (APT) package manager as follows −

[jeryy]$ sudo apt-get update
[jeryy]$ sudo apt-get install gawk

Similarly, to install AWK on RPM based GNU/Linux, use Yellowdog Updator Modifier yum package manager as follows −

[root]# yum install gawk

After installation, ensure that AWK is accessible via command pne.

[jerry]$ which awk

On executing the above code, you get the following result −

/usr/bin/awk

Installation from Source Code

As GNU AWK is a part of the GNU project, its source code is available for free download. We have already seen how to install AWK using package manager. Let us now understand how to install AWK from its source code.

The following installation is apppcable to any GNU/Linux software, and for most other freely-available programs as well. Here are the installation steps −

Step 1 − Download the source code from an authentic place. The command-pne utipty wget serves this purpose.

[jerry]$ wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.1.tar.xz

Step 2 − Decompress and extract the downloaded source code.

[jerry]$ tar xvf gawk-4.1.1.tar.xz

Step 3 − Change into the directory and run configure.

[jerry]$ ./configure

Step 4 − Upon successful completion, the configure generates Makefile. To compile the source code, issue a make command.

[jerry]$ make

Step 5 − You can run the test suite to ensure the build is clean. This is an optional step.

[jerry]$ make check

Step 6 − Finally, install AWK. Make sure you have super-user privileges.

[jerry]$ sudo make install

That is it! You have successfully compiled and installed AWK. Verify it by executing the awk command as follows −

[jerry]$ which awk

On executing this code, you get the following result −

/usr/bin/awk
Advertisements