awk从入门到入土(21)awk脚本调试

Posted 奇妙之二进制

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了awk从入门到入土(21)awk脚本调试相关的知识,希望对你有一定的参考价值。

awk支持调试模式,像gdb一样设置断点、单步调试awk脚本。

cmake  commands  Desktop            Downloads  etc  FlameGraph        g.h   k.cc  l     lib   main.cc  Music  perf.data.old  pol       script.awk  snap   test2      Videos
victory@victory-ThinkPad-T490:~$ cat script.awk 
#!/usr/bin/awk -f

BEGIN 
	for (i = 1; i <= 5; ++i) 
		print i 


victory@victory-ThinkPad-T490:~$ awk --debug -f script.awk 
gawk> h
backtrace:
	backtrace [N] - print trace of all or N innermost (outermost if N < 0) frames
break:
	break [[filename:]N|function] - set breakpoint at the specified location
clear:
	clear [[filename:]N|function] - delete breakpoints previously set
commands:
	commands [num] - starts a list of commands to be executed at a breakpoint(watchpoint) hit
condition:
	condition num [expr] - set or clear breakpoint or watchpoint condition
continue:
	continue [COUNT] - continue program being debugged
delete:
	delete [breakpoints] [ran

以上是关于awk从入门到入土(21)awk脚本调试的主要内容,如果未能解决你的问题,请参考以下文章

awk从入门到入土(12)awk也可以写脚本,替代shell

awk从入门到入土awk初次会面

awk从入门到入土(20)awk解析命令行参数

awk从入门到入土(20)awk解析命令行参数

awk从入门到入土(17)awk多行写法

文本三剑客之awk-从入门到入土