ARGC        The number of command line arguments (does not include
                   options to gawk, or the program source).   命令行参数的个数
ARGIND      The index in ARGV of the current file being processed. 命令行中文件序号
ARGV        Array of command line arguments. The array is indexed
                   from 0 to ARGC - 1. Dynamically changing the contents
                   of ARGV can control the files used for data. 命令行参数数组

参考来源:https://blog.csdn.net/liuzhoulong/article/details/7879300

直接替代码(脚本名为parallel.awk):

 BEGIN{
print "HELLO!"
for(i=;i<ARGC;i++)
{
print ARGV[i];
}
}
{
if(ARGIND==)
{
print "1_"$;
}
else if(ARGIND ==)
{
print "2_"$;
}
else if(ARGIND==)
{
print "3_"$;
}
}
END{ }

解析文件:

1.txt

       a
b
c

2.txt

       a
b
c

3.txt

       a
b
c

执行awk脚本: awk -f parallel.awk 1.txt 2.txt 3.txt

结果如下:

HELLO!
awk
.txt
.txt
.txt
1_1 a
1_2 b
1_3 c
2_4 a
2_5 b
2_6 c
3_7 a
3_8 b
3_9 c

关于NR,FNR:当前文件的行号FNR;总的行号是NR。

斜杠互相替换:

gsub(/\\/,"/",str);

gsub("/","\\",info);

解析为sql语句的时候,经常会遇到单引号的问题:

printf("select * from acct where log_datetime between '\''2018-10-15 00:00:00'\'' and '\''2018-10-15 23:59:59'\'' and name in (%s);",str);

最新文章

  1. css面包屑导航编号
  2. ANT的安装
  3. CSS应用心得
  4. yum标准化安装nginx最新版
  5. CSS3新添加的属性
  6. 在c#中使用log4net
  7. Eclipse全屏及插件下载
  8. jmeter压测SSL加密网站
  9. URAL 1180. Stone Game (博弈 + 规律)
  10. 基于Office 365 无代码工作流分析-需求基本分析!
  11. 201521123115《Java程序设计》第14周学习总结
  12. Android Studio 2.3 instant run与miui冲突问题的解决
  13. Linux的文本处理工具浅谈-awk sed grep
  14. Python random() 函数
  15. 记自己在spring中使用redis遇到的两个坑
  16. Emote木马分析
  17. selector 模块
  18. go基本操作
  19. [转] YUM 源优先级插件:Yum Priorities
  20. IEEEXtreme 10.0 - Checkers Challenge

热门文章

  1. 如何在静态方法或非Spring Bean中注入Spring Bean
  2. (转)Django 数据库
  3. PSP总结
  4. 20162328蔡文琛 week05 大二
  5. Oracle Form Builder
  6. mysql 性能分析及explain用法
  7. grunt入门讲解2:如何使用 Gruntfile 配置任务
  8. Mongodb compass 介绍
  9. 蜗牛慢慢爬 LeetCode 5.Longest Palindromic Substring [Difficulty: Medium]
  10. Beta阶段DAY2