- 论坛徽章:
- 0
|
本帖最后由 小小linux 于 2011-04-20 15:38 编辑
看了IBM awk学习资料。里面有个 关于 多行记录的例子。。
文件如下。
Jimmy the Weasel
100 Pleasant Drive
San Francisco, CA 12345
Big Tony
200 Incognito Ave.
Suburbia, WA 67890
我们希望 awk 将每 3 行看作是一个独立的记录,而不是三个独立的记录
希望得到的结果是:
Jimmy the Weasel, 100 Pleasant Drive, San Francisco, CA 12345
Big Tony, 200 Incognito Ave., Suburbia, WA 67890
我的awk脚本
[root@localhost bin]# more add.awk
BEGIN {
FS="\n"
RS=""
}
{
print $1“,"$2","$3
}
但是运行之后只显示一行。。
[root@localhost bin]# awk -f add.awk add
Jimmy the Weasel, 100 Pleasant Drive, San Francisco, CA 12345 |
|