awk 'sub(" ","#") {print $3,$4}' log

本文通过一个具体的示例展示了如何使用AWK命令进行简单的文本替换和字段提取操作。首先使用`sub`函数将日志文件中特定字符进行替换,并进一步提取了修改后的第三和第四个字段。这些操作对于处理和分析日志文件特别有用。
[omc@answar shuai]$ cat log 
Driver te    2E00000 1048576          44     1048532     1048532     1048532

[omc@answar shuai]$ 


[omc@answar shuai]$ awk 'sub(" ","#")' log 
Driver#te    2E00000 1048576          44     1048532     1048532     1048532
[omc@answar shuai]$ 


[omc@answar shuai]$ awk 'sub(" ","#") {print $3,$4}' log 
1048576 44
[omc@answar shuai]$ 

#!/bin/tcsh # Base path set BASE_PATH = "/home/imx952_be/usr/ryan_nxg00919/SOC_BE_IMX952_CLN16FFC_1.7/backend/imx952_be_blocks" # Mix list set mix_list = ( \ imx952_aonmix_wrapper_be \ imx952_bbsmmix_wrapper_be \ imx952_ccmsrcgpcmix_wrapper_be \ imx952_ddrmix_wrapper_be \ imx952_displaymix_wrapper_be \ ) # Loop through each mix foreach mix ($mix_list) echo "===== MIX: $mix =====" set R2G_ROOT = "$BASE_PATH/$mix/tool_data/nxplugins/LEC_RUN_DIR/R2G" set G2G_ROOT = "$BASE_PATH/$mix/tool_data/nxplugins/LEC_RUN_DIR/G2G" set r2g_candidates = ( `find -L "$R2G_ROOT" -type f -name "lec.r2g*.log"` ) set g2g_candidates = ( `find -L "$G2G_ROOT" -type f -name "lec.g2g*.log"` ) if ( $#r2g_candidates > 0 ) then set latest_r2g_log = `ls -1t $r2g_candidates | head -1` set r2g_run = $latest_r2g_log:h:h:h:h else set latest_r2g_log = "" set r2g_run = "N/A" endif if ( $#g2g_candidates > 0 ) then set latest_g2g_log = `ls -1t $g2g_candidates | head -1` set g2g_run = $latest_g2g_log:h:h:h:h else set latest_g2g_log = "" set g2g_run = "N/A" endif echo "-- R2G Info --" echo "Run Path: $r2g_run" set r2g_rev_net = "N/A" set r2g_g_upf = "N/A" set r2g_r_upf = "N/A" set r2g_stat = "N/A" if ( "$latest_r2g_log" != "" ) then set r2g_rev_net = `grep -i &#39;set[[:space:]]*revised_verilog_files&#39; "$latest_r2g_log" | head -1 | awk -F&#39;"&#39; &#39;NR==1{print $2}&#39; | awk &#39;{print $1}&#39;` if ( "$r2g_rev_net" == "" ) then set r2g_rev_net = `awk &#39;BEGIN{IGNORECASE=1} /read_design/ && /-revised/ {for(i=1;i<=NF;i++){ if(tolower($i)=="-revised" && i<NF && substr($(i+1),1,1)!="-"){ print $(i+1); exit } }}&#39; "$latest_r2g_log"` if ( "$r2g_rev_net" == "" ) set r2g_rev_net = "N/A" endif set r2g_g_upf_path = `awk &#39;BEGIN{IGNORECASE=1} /read_power_intent/ && /-golden/ {for(i=1;i<=NF;i++){ if(tolower($i)=="-golden" && i<NF && substr($(i+1),1,1)!="-"){ print $(i+1); exit } }}&#39; "$latest_r2g_log"` if ( "$r2g_g_upf_path" != "" ) then set upf_file = "$r2g_g_upf_path:t" set r2g_g_upf_rev = `grep -F "$upf_file" "$latest_r2g_log" | grep &#39;$Revision&#39; | sed -n &#39;s/.*Revision:[[:space:]]*\([^[:space:]]*\).*/\1/p&#39; | head -1` if ( "$r2g_g_upf_rev" == "" ) set r2g_g_upf_rev = "N/A" set r2g_g_upf = "$r2g_g_upf_path (Rev: $r2g_g_upf_rev)" endif set r2g_r_upf_path = `awk &#39;BEGIN{IGNORECASE=1} /read_power_intent/ && /-revised/ {for(i=1;i<=NF;i++){ if(tolower($i)=="-revised" && i<NF && substr($(i+1),1,1)!="-"){ print $(i+1); exit } }}&#39; "$latest_r2g_log"` if ( "$r2g_r_upf_path" != "" ) then set upf_file = "$r2g_r_upf_path:t" set r2g_r_upf_rev = `grep -F "$upf_file" "$latest_r2g_log" | grep &#39;$Revision&#39; | sed -n &#39;s/.*Revision:[[:space:]]*\([^[:space:]]*\).*/\1/p&#39; | head -1` if ( "$r2g_r_upf_rev" == "" ) set r2g_r_upf_rev = "N/A" set r2g_r_upf = "$r2g_r_upf_path (Rev: $r2g_r_upf_rev)" endif set r2g_stat = `grep -i "Compare Results:" "$latest_r2g_log" | sed -n &#39;s/.*Compare Results:[[:space:]]*//p&#39; | tail -1` if ( "$r2g_stat" == "" ) set r2g_stat = "N/A" endif echo "Revised Netlist: $r2g_rev_net" echo "Golden UPF: $r2g_g_upf" echo "Revised UPF: $r2g_r_upf" echo "Compare Results: $r2g_stat" echo "-- G2G Info --" echo "Run Path: $g2g_run" set g2g_g_net = "N/A" set g2g_r_net = "N/A" set g2g_g_upf = "N/A" set g2g_r_upf = "N/A" set g2g_stat = "N/A" if ( "$latest_g2g_log" != "" ) then set g2g_g_net = `grep -i &#39;set[[:space:]]*golden_verilog_files&#39; "$latest_g2g_log" | head -1 | awk -F&#39;"&#39; &#39;NR==1{print $2}&#39; | awk &#39;{print $1}&#39;` if ( "$g2g_g_net" == "" ) then set g2g_g_net = `awk &#39;BEGIN{IGNORECASE=1} /read_design/ && /-golden/ {for(i=1;i<=NF;i++){ if(tolower($i)=="-golden" && i<NF && substr($(i+1),1,1)!="-"){ print $(i+1); exit } }}&#39; "$latest_g2g_log"` if ( "$g2g_g_net" == "" ) set g2g_g_net = "N/A" endif set g2g_r_net = `grep -i &#39;set[[:space:]]*revised_verilog_files&#39; "$latest_g2g_log" | head -1 | awk -F&#39;"&#39; &#39;NR==1{print $2}&#39; | awk &#39;{print $1}&#39;` if ( "$g2g_r_net" == "" ) then set g2g_r_net = `awk &#39;BEGIN{IGNORECASE=1} /read_design/ && /-revised/ {for(i=1;i<=NF;i++){ if(tolower($i)=="-revised" && i<NF && substr($(i+1),1,1)!="-"){ print $(i+1); exit } }}&#39; "$latest_g2g_log"` if ( "$g2g_r_net" == "" ) set g2g_r_net = "N/A" endif set g2g_g_upf_path = `awk &#39;BEGIN{IGNORECASE=1} /read_power_intent/ && /-golden/ {for(i=1;i<=NF;i++){ if(tolower($i)=="-golden" && i<NF && substr($(i+1),1,1)!="-"){ print $(i+1); exit } }}&#39; "$latest_g2g_log"` if ( "$g2g_g_upf_path" != "" ) then set upf_file = "$g2g_g_upf_path:t" set g2g_g_upf_rev = `grep -F "$upf_file" "$latest_g2g_log" | grep &#39;$Revision&#39; | sed -n &#39;s/.*Revision:[[:space:]]*\([^[:space:]]*\).*/\1/p&#39; | head -1` if ( "$g2g_g_upf_rev" == "" ) set g2g_g_upf_rev = "N/A" set g2g_g_upf = "$g2g_g_upf_path (Rev: $g2g_g_upf_rev)" endif set g2g_r_upf_path = `awk &#39;BEGIN{IGNORECASE=1} /read_power_intent/ && /-revised/ {for(i=1;i<=NF;i++){ if(tolower($i)=="-revised" && i<NF && substr($(i+1),1,1)!="-"){ print $(i+1); exit } }}&#39; "$latest_g2g_log"` if ( "$g2g_r_upf_path" != "" ) then set upf_file = "$g2g_r_upf_path:t" set g2g_r_upf_rev = `grep -F "$upf_file" "$latest_g2g_log" | grep &#39;$Revision&#39; | sed -n &#39;s/.*Revision:[[:space:]]*\([^[:space:]]*\).*/\1/p&#39; | head -1` if ( "$g2g_r_upf_rev" == "" ) set g2g_r_upf_rev = "N/A" set g2g_r_upf = "$g2g_r_upf_path (Rev: $g2g_r_upf_rev)" endif set g2g_stat = `grep -i "Compare Results:" "$latest_g2g_log" | sed -n &#39;s/.*Compare Results:[[:space:]]*//p&#39; | tail -1` if ( "$g2g_stat" == "" ) set g2g_stat = "N/A" endif echo "Golden Netlist: $g2g_g_net" echo "Revised Netlist: $g2g_r_net" echo "Golden UPF: $g2g_g_upf" echo "Revised UPF: $g2g_r_upf" echo "Compare Results: $g2g_stat" echo "-- CLP Info --" set CLP_ROOT = "$BASE_PATH/$mix/tool_data/nxplugins/CLP_run_dir" set clp_logs = ( `find -L "$CLP_ROOT" -type f -name "clp*.log" -printf "%T@ %p\n" | sort -nr | awk &#39;{print $2}&#39;` ) set clp_log_path = "N/A" if ( "$clp_log_path" != "N/A" && -e "$clp_log_path" ) then set clp_netlist = `grep -i -- "-sensitive" "$clp_log_path" | head -1 | awk -F&#39;"&#39; &#39;{print $2}&#39; | awk &#39;{print $1}&#39;` if ( "$clp_netlist" == "" ) set clp_netlist = "N/A" endif set clp_no_waiver_issues = "N/A" set clp_waiver_status = "N/A" if ( $#clp_logs > 0 ) then set clp_log_path = "$clp_logs[1]" if ( "$clp_log_path" != "N/A" && -e "$clp_log_path" ) then set clp_netlist = `grep -i -- "-sensitive" "$clp_log_path" | head -1 | awk -F&#39;"&#39; &#39;{print $2}&#39; | awk &#39;{print $1}&#39;` if ( "$clp_netlist" == "" ) set clp_netlist = "N/A" endif if ( "$clp_netlist" == "" ) set clp_netlist = "N/A" set clp_base_dir = "$clp_log_path:h:h" set rpt_no_waiver = "$clp_log_path:h/report_postroute/clp_postroute.rule_check_lp.rpt" set rpt_with_waiver = "$clp_log_path:h/report_postroute_with_waiver/clp_postroute.rule_check_lp.rpt" if ( -e "$rpt_no_waiver" ) then if ( -e "$rpt_no_waiver" ) then if ( -e "$rpt_no_waiver" ) then set line_count = `wc -l < "$rpt_no_waiver"` @ clp_no_waiver_issues = $line_count / 2 else set clp_no_waiver_issues = "N/A" endif @ clp_no_waiver_issues = $line_count / 2 else set clp_no_waiver_issues = "N/A" endif @ clp_no_waiver_issues = $line_count / 2 endif if ( -e "$rpt_with_waiver" ) then set file_size = `stat -c %s "$rpt_with_waiver"` if ( $file_size == 0 ) then set clp_waiver_status = "PASS" else set clp_waiver_status = "FAIL" endif else set clp_waiver_status = "N/A" endif if ( -e "$rpt_with_waiver" ) then set file_size = `stat -c %s "$rpt_with_waiver"` if ( $file_size == 0 ) then set clp_waiver_status = "PASS" else set clp_waiver_status = "FAIL" endif else set clp_waiver_status = "N/A" endif set file_size = `stat -c %s "$rpt_with_waiver"` if ( $file_size == 0 ) then set clp_waiver_status = "PASS" else set clp_waiver_status = "FAIL" endif else set clp_waiver_status = "N/A" endif if ( $file_size == 0 ) then set clp_waiver_status = "PASS" else set clp_waiver_status = "FAIL" endif endif endif echo "CLP Log Path: $clp_log_path" echo "Sensitive Netlist: $clp_netlist" echo "No Waiver Issues: $clp_no_waiver_issues" echo "Run with Waiver: $clp_waiver_status" echo "" end
最新发布
08-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值