How to use AWK regular expressions under Linux system

  
                

AWK is a regular expression and an important text processing tool. In Linux systems, AWK is also an engine for data processing. There are three general forms of using AWK rules under Linux. Let's take a closer look at how to use AWK regular expressions under Linux.

in the form of a (similar analysis with you):

awk & lsquo; /regular /{body treatment} & rsquo; file

0 $ default matching, rather After $0~/regular/

, the matching content will be printed by default after the regular match, so if the main statement is just print, it can be omitted directly.

Form 2:

awk ‘{if($4~/root/) print}’ file

Use regularity in the if statement of the body statement.

Form 3:

awk ‘{built-in string handling function}’ file

Use regular rules in awk's built-in string handling functions, such as sub, gsub , gensub, match, etc.

echo “ABC^H^H^H^HDEF”

Copyright © Windows knowledge All Rights Reserved