This chapter describes how to set up the AWK environment on your GNU/Linux system.
The following installation is applicable 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-line utility wget serves this purpose.
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 gawkSimilarly, to install AWK on RPM based GNU/Linux, use Yellowdog Updator Modifier yum package manager as follows −
[root]# yum install gawkAfter installation, ensure that AWK is accessible via command line.
[jerry]$ which awkOn 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 applicable 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-line utility wget serves this purpose.
[jerry]$ wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.1.tar.xzStep 2 − Decompress and extract the downloaded source code.
[jerry]$ tar xvf gawk-4.1.1.tar.xzStep 3 − Change into the directory and run configure.
[jerry]$ ./configureStep 4 − Upon successful completion, the configure generates Makefile. To compile the source code, issue a make command.
[jerry]$ makeStep 5 − You can run the test suite to ensure the build is clean. This is an optional step.
[jerry]$ make checkStep 6 − Finally, install AWK. Make sure you have super-user privileges.
[jerry]$ sudo make installThat is it! You have successfully compiled and installed AWK. Verify it by executing the awk command as follows −
[jerry]$ which awkOn executing this code, you get the following result −
/usr/bin/awk
No comments:
Post a Comment