[Reprint]awk, Nawk, Mawk, Gawk's brief introduction

Source: Internet
Author: User

Reprinted from: http://blog.sina.com.cn/s/blog_3d2d79aa0100h47h.html

Awk is a programming language that is used to process text and data under Linux/unix. The data can come from standard input , one or more files , or the output of other commands (that is, pipelines). It supports advanced functions such as user- defined functions and dynamic Regular Expressions , and is a powerful programming tool under Linux/unix. It is used in the command line, but more is used as a script.

awk handles text and data in such a way that it scans the file line-by- row, from the first line to the last line, looks for rows that match a particular pattern, and makes the actions you want on those lines . If no processing action is specified, the matching rows are displayed to the standard output (screen), that is, the default processing action is print, and if no pattern is specified, all rows specified by the operation are processed, that is, the default specified mode is all . Awk represents the first letter of its author's last name, respectively. Because its author is three people, respectively is Alfred Aho, Brian Kernighan, Peter Weinberger. Gawk is the GNU version of AWK, which provides some extensions to the Bell Lab and GNU.

Like the shell, there are several types of awk, commonly known as awk,Nawk,mawk,gawk, which

awk: Originally completed in 1 9 7 7 years, 1 9 8 5 published a new version of AWK, which has a lot more functionality than the old version, and awk can use a short program to modify, compare, extract, print, and so on in a document, if you use a language such as C or p a s c a l Order to complete the above tasks will be very inconvenient and time-consuming, the written procedures will be very large;

Nawk: In the mid 1980s, the awk language was updated and, to varying degrees, replaced with an enhanced version called Nawk (New awk). The old awk interpreter still exists in many systems, but it is usually installed as the Oawk (older awk) command, while the Nawk interpreter is installed as the primary awk command, or you can use the Nawk command. Dr. Kernighan is still maintaining the Nawk, which, like Gawk, is open source and available free of charge;

Mawk: Mawk is an interpreter for the AWK programming language. The awk language is widely used in the retrieval and processing of multimedia data files and text, as well as in the prototype design and testing of algorithms. Mawk brings a new concept to awk, which is implemented in the AWK programming Language (Aho, Kernighan and Weinberger, the awk programming Language, Addison-we Sley Publishing, 1988. is considered to be the AWK Handbook. ) is defined in the awk language. Mawk follows the awk language defined by POSIX 1003.2 (draft 11.3), contains some features not mentioned in the AWK manual, while Mawk provides a small extension, and is said to be the fastest awk for Mawk;

gawk: is an open source implementation of the AWK interpreter for GNU Project. Although the earlier GAWK release was an alternative to the old AWK, it was constantly updated to include Nawk features;

At present, we are more inclined to use awk and gawk, in this article the awk is to introduce the gawk of gun as an example. The various awk option settings in the Ubuntu system can be done with sudo update-alternatives--config awk , which you can actually do by manually modifying the soft links. When Debian was minimized, Awk's links were pointing to Mawk.

[Reprint]awk, Nawk, Mawk, Gawk's brief introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.