694 B
694 B
awk 使用
[TOC]
参考
https://blog.csdn.net/daily886/article/details/85156557
基本规则
awk [-F|-f|-v] ‘BEGIN{} //{command1; command2} END{}’ file
常用形式:
Awk -F '' '//{command}' file
- -F 'char': 确定分割符,默认分隔符是空格
- 常用变脸$0 $1 $2 ... 0代表正行,1代表第一个切片
- 格式化输出 awk '/pattern/ {printf "echo 1st %s", $1}' file
- 匹配规则在//之间
常用
awk 中执行shell命令
对于 某行数据 Version = "v1.2.3"
自动打标签并推送
awk -F '"' '/Version/ {print $2;system("git tag "$2);system("git push origin "$2)}' onebd.go
注意:在makefile中使用时$需用$$代替