In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you how to use awk, regular expressions, regular operators in linux, I believe most people still do not know how to use, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
Regular expressions are essential to using awk as a text processing tool. To master the use of regular expressions with this tool. In fact, we do not have to learn its regular expressions separately. Regular expressions are like a programming language that has its own syntax rules that already express meaning. For different tools, most of them actually mean the same thing. Regular expressions are used in many linux text processing tools (awk,sed,grep,perl). There are only three types. For details, see: Linux shell regular expressions (BREs,EREs,PREs) differences comparison. As long as certain tools are regular expressions of a certain type. So its grammar rules are basically the same. From that article, we know that awk's regular expressions belong to: Extended Regular Expressions (EREs).
awk Extended Regular _Expression (ERES)
Character feature + specifies that strings match if one or more characters or specific values of extended regular expressions (preceded by +(plus sign)) are in the string. Command line: awk '/smith+ern/' testfile
Prints any record containing a string of characters smit followed by one or more h characters ending in the character ern to standard output. The output in this example is:
smithern, harry smithhern, anne
? Specifies if zero or one character or the specific value of the extended regular expression (in? (before the question mark) in a string, the string matches. Command line: awk '/smith?/ ' testfile
Prints all records containing instances of the character smit followed by zero or one h character to standard output. The output in this example is:
smith, alan smithern, harry smithhern, anne smitters, alexis
|Specify if| (vertical line) is in the string, the string matches. Command line: awk '/allen| alan /' testfile
Prints all records containing the string allen or alan to standard output. The output in this example is:
smiley, allen smith, alan
( ) Combines strings together in regular expressions. Command line: awk '/a(ll)? (nn)? e/' testfile
Prints all records with the string ae or alle or anne or allnne to standard output. The output in this example is:
smiley, allen smithhern, anne
{m}Specifies that strings match if exactly m pattern instances are in the string. Command line: awk '/l{2}/' testfile
Print to standard output
smiley, allen
{m,} Specifies that strings match if at least m pattern instances are in the string. Command line: awk '/t{2,}/' testfile
Print to standard output:
smitters, alexis
{m, n} specifies if the concrete values of m and n inclusive patterns are in the string where m
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.