利用awk命令拆分log中路径和行号

原始数据文件-error528.txt,内容摘取如下:

9941 (Local) /home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_allocator.c:201 FMM.MIGHT (2:Error) Analyze

21163 (Local) /home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/fs/proc/version.c:76 MLK.RET.MIGHT (2:Error) Analyze

31816 (Local) /home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:37 MLK.MUST (2:Error) Analyze

31817 (Local) /home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:37 MLK.MUST (2:Error) Analyze

31818 (Local) /home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:40 MLK.MUST (2:Error) Analyze

……

第一步:取出路径和行号

awk '{print $3}' error528.txt > pathLine.txt

命令解析:将文件error528.txt”中利用空格分隔的第三列摘取并输出到文件“pathLine.txt”。

 

pathLine.txt内容摘取:

/home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_allocator.c:201

/home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/fs/proc/version.c:76

/home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:37

/home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:37

/home/zeos/gaojianyun/daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:40

……

第二步:去掉头部/home/zeos/gaojianyun/

awk -F '/home/zeos/gaojianyun/' '{print $2}' pathLine.txt > pathLine2.txt

命令解析:-F参数为自定义分隔符。以'/home/zeos/gaojianyun/'作为分隔符,将每列其后面部分输出到pathLine2.txt文件

 

pathLine2.txt内容摘取:

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_allocator.c:201

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/fs/proc/version.c:76

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:37

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:37

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c:40

……

 

第三步:获取路径

awk -F : '{print $1}' pathLine2.txt  > path.txt

命令解析:以“:”为分隔符,输出“:”前面部分到path.txt文件

 

path.txt内容摘取:

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_allocator.c

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/fs/proc/version.c

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c

daily_1453/SQ/release/xitos/core/kw_build/tmp/work-shared/saic_imx6d_fota/kernel-source/drivers/clk/clk-conf.c

……

 

第四步:获取行号

awk -F : '{print $2}' path.txt  > line.txt

命令解析:以“:”为分隔符,输出“:”后面部分到line.txt文件

 

line.txt内容摘取:

201

76

37

37

40

……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值