码迷,mamicode.com
首页 > 其他好文 > 详细

awk

时间:2014-08-25 16:40:14      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:文件   line   sp   c   file   as   print   bs   ca   

filename  当前输入文件的名称

NR 当前输入文件的总行数

NF 当前行记录中的字段数

OFS 输出字段的分隔符

FS 输入字段的分隔符

awk ‘{print "%s %-8s\n",$3,$1}‘ filename

cat /etc/passwd|awk ‘{FS=":"} $3<10 {print $1 "\t" $3}‘

[root@test~]# last|tail|awk ‘{print $1 "\t lines:" NR "\t colunmes:"NF}‘
root lines:1 colunmes:9
reboot lines:2 colunmes:11
root lines:3 colunmes:9
reboot lines:4 colunmes:11
root lines:5 colunmes:9
reboot lines:6 colunmes:11
root lines:7 colunmes:9
reboot lines:8 colunmes:11
lines:9 colunmes:0
wtmp lines:10 colunmes:7

awk

标签:文件   line   sp   c   file   as   print   bs   ca   

原文地址:http://www.cnblogs.com/lehao/p/3935003.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!