Function
5.1 rand () Functions
Awk 'in in {print rand (); print srand ()} 'test.txt
5.2 gsub (x, y, z) Functions
In string Z, use string y to replace all strings that match the regular expression X. The default value of Z is $0.
Awk-F: 'gsub (/root/, "CCC", $0) {print $0} '/etc/passwd
CCC: X: 0: 0: CCC:/bin/bash
5.3 sub (x, y, z) Functions
In string Z, use string y to replace the first string that matches Regular Expression X. The default value of Z is $0.
Awk-F: 'sub (/CCC/, "root", $0) {print $0} '/etc/passwd
CCC: X: 0: 0: CCC:/bin/bash
5.4 length (z) Function
Purpose: display the length of each line in the test.txt document:
Awk '{print length ()}'/usr/local/src/Allen/test.txt
5.5 Getline () function
DF-H | awk '{If (NF = 1) {Getline; print $3}; If (NF = 6) Print $4 }'
DF-H | awk 'in in {print "Disk Free :"}\
{If (NF = 1) {Getline; print $3}; If (NF = 6) {print $4 }}'