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

awk 中 FS的用法

时间:2016-05-20 09:59:27      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:

在openwrt文件 ar71xx.sh中

查询设备类型时,有这么一句,

machine=$(awk ‘BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}‘ /proc/cpuinfo)
解决:
1)查看cpuinfo
root@hbg:/dev# cat  /proc/cpuinfo
system type             : Qualcomm Atheros QCA9533 rev 2
machine                 : Atheros AP143 reference board
processor               : 0
cpu model               : MIPS 24Kc V7.4
BogoMIPS                : 432.53
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 16
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 4, address/irw mask: [0x0000, 0x0ff8, 0x0ff8, 0x0ff8]
isa                     : mips1 mips2 mips32r1 mips32r2
ASEs implemented        : mips16
shadow register sets    : 1
kscratch registers      : 0
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available
2)awk截取信息, FS为指定格式; 以 “:” 冒号为分界符,两边都是制表符"\t",第二个参数
   /machine指定了以machine为开始的那一行
  
所以命令的结果是:
Atheros AP143 reference board  

awk 中 FS的用法

标签:

原文地址:http://www.cnblogs.com/rohens-hbg/p/5510890.html

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