标签:pre $0 awk html 记录 code employee variable art
AWK 记录和域
The NR Variable
% awk ‘{print NR, $0}‘ employees 1 Tom Jones 4424 5/12/66 543354 2 Mary Adams 5346 11/4/63 28765 3 Sally Chang 1654 7/22/54 650000 4 Billy Black 1683 9/23/44 336500
$0 代表整行
NF 文件列数
% awk ‘{print $0, NF}‘ employees Tom Jones 4444 5/12/66 543354 5 Mary Adams 5346 11/4/63 28765 5 Sally Chang 1654 7/22/54 650000 5 Billy Black 1683 9/23/44 336500 5
% cat employees Tom Jones:4424:5/12/66:543354 Mary Adams:5346:11/4/63:28765 Sally Chang:1654:7/22/54:650000 Billy Black:1683:9/23/44:336500 % awk –F: ‘/Tom Jones/{print $1, $2}‘ employees2 Tom Jones 4424
eg2
% awk –F‘[ :\t]‘ ‘{print $1, $2, $3}‘ employees Tom Jones 4424 Mary Adams 5346 Sally Chang 1654 Billy Black 1683
总结:学习了NR NF 变量 学会使用-F參数
标签:pre $0 awk html 记录 code employee variable art
原文地址:http://www.cnblogs.com/jzssuanfa/p/6849731.html