首页 技术 正文
技术 2022年11月14日
0 收藏 825 点赞 2,445 浏览 818 个字

awk -F”[01]” ‘{}’  这种形式指定的分隔符是或的关系,即0或1作为分隔符;
awk -F”[0][1]” ‘{}’ 这种形式指定的分隔符是合并的关系,即以“01”作为一个字符为分隔符。

故假如有test.txt文本文件只有一行:

1. mail from: tomcat@gmail.com  2. subject:hello  3. data:2012-07-12 17:00  4. content:Hello, The world.  5.   6. mail from: jerry@gmail.com  7. subject:congregation  8. data:2012-07-12 08:31  9. content:Congregation to you.  10.   11. mail from: jacob@gmail.com  12. subject:Test  13. data:2012-07-12 10:20  14. content:This is a test mail.

用命令:awk  ‘BEGIN {FS=”[0-9]+[.]”;OFS=”\n”}{for(i=1;i<=NF;i++) printf(“%d  %s\n”,i,$i)}’ test.txt即可输出如下格式的形式的文件:

1  
2   mail from: tomcat@gmail.com  
3   subject:hello  
4   data:2012-07-12 17:00  
5   content:Hello, The world.  
6     
7   mail from: jerry@gmail.com  
8   subject:congregation  
9   data:2012-07-12 08:31  
10   content:Congregation to you.  
11     
12   mail from: jacob@gmail.com  
13   subject:Test  
14   data:2012-07-12 10:20  
15   content:This is a test mail.

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905