AWK LINXU Three Musketeers

AWK main functions: taking rows, columns taken, statistics
basic format:
awk -F 'divided character' '{print $ 1}' file name

awk logic diagram:
awk ----------------- the contents of the BEGIN module (BEGIN '{print $ 1} ')

Reading the first line of text (a row read) the output result satisfies ----
    不满足则下一行继续读直到读完整个文本内容                    

awk -F 'divided character' '{print $ 0}' file name column represents a comprehensive information display
$ 0 represents a scalar, meaning all

awk can also be used to find
awk '/ character /' filename

Plus the matching process action

awk also support regular

The difference between NF and NR (NF is the number of storage columns, NR is the number of rows of storage)

awk -F ':' '$ 1 ~ / ^ root /' / etc / passwd ~ indicates a match
awk -F ':' '$ NF ~ / bash $ /' / etc / passwd

$ NF value refers to the last one of

awk usage in comparison size, equal to operators of
example: the current statistical average user how many?

Statistics disk partition usage?
df | awk NR == 2 | awk '$ 3 <1000000 {print $ 4}' in the second row third column statistics (used used) is greater than 1,000,000, then outputs it to the fourth column (remaining available Available)
DF | awk ' / \ / $ / '| awk ' $ 3> 1000000 {print $ 4} ' matches the information to the third column / end (used used) is greater than 1,000,000, then outputs it to the fourth column (remaining available available)

awk filtering ip address

awk batch create users, the use of dynamic password and save
AWK LINXU Three Musketeers

Guess you like

Origin blog.51cto.com/13858002/2425082