awk getline
2013-05-15 17:29
169 查看
[root@localhost ~]# cat a.txt
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 h
9 i
0 j
[root@localhost ~]# awk '{while(getline>0) print $0,NF,FNR,NR}' a.txt
2 b 2 2 2
3 c 2 3 3
4 d 2 4 4
5 e 2 5 5
6 f 2 6 6
7 g 2 7 7
8 h 2 8 8
9 i 2 9 9
0 j 2 10 10
[root@localhost ~]# awk '{while(getline v>0) print v,NF,FNR,NR}' a.txt
2 b 2 2 2
3 c 2 3 3
4 d 2 4 4
5 e 2 5 5
6 f 2 6 6
7 g 2 7 7
8 h 2 8 8
9 i 2 9 9
0 j 2 10 10
[root@localhost ~]# awk '{while((getline < "a.txt")>0) print $0,NF,FNR,NR}' a.txt
1 a 2 1 1
2 b 2 1 1
3 c 2 1 1
4 d 2 1 1
5 e 2 1 1
6 f 2 1 1
7 g 2 1 1
8 h 2 1 1
9 i 2 1 1
0 j 2 1 1
[root@localhost ~]# awk '{while((getline v < "a.txt")>0) print v,NF,FNR,NR}' a.txt
1 a 2 1 1
2 b 2 1 1
3 c 2 1 1
4 d 2 1 1
5 e 2 1 1
6 f 2 1 1
7 g 2 1 1
8 h 2 1 1
9 i 2 1 1
0 j 2 1 1
[root@localhost ~]# awk '{while(("cat a.txt" | getline)>0) print $0,NF,FNR,NR}' a.txt
1 a 2 1 1
2 b 2 1 1
3 c 2 1 1
4 d 2 1 1
5 e 2 1 1
6 f 2 1 1
7 g 2 1 1
8 h 2 1 1
9 i 2 1 1
0 j 2 1 1
[root@localhost ~]# awk '{while(("cat a.txt" | getline v)>0) print v,NF,FNR,NR}' a.txt
1 a 2 1 1
2 b 2 1 1
3 c 2 1 1
4 d 2 1 1
5 e 2 1 1
6 f 2 1 1
7 g 2 1 1
8 h 2 1 1
9 i 2 1 1
0 j 2 1 1
本文出自 “notepad” 博客,请务必保留此出处http://sndapk.blog.51cto.com/5385144/1201041
相关文章推荐
- awk调用shell命令 getline system
- awk(3)-awk getline
- awk+system+getline
- c++中 cin、cin.get()、cin.getline()、getline()、gets()函数的用法
- C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- cin.get()与cin.getline()函数讲解1
- C++语言中cin cin.getline cin.get getline gets getchar 的用法实例
- C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- scanf、gets、getchar、cin、cin.get、cin.getline、getline总结
- QTabWiget Remove Line Border 去除边框
- c++@ cin,cin.gets(),cin.getline() 详解
- C++中cin、cin.get()、cin.getline()、getline()、gets()函数的用法
- cin、cin.get()、cin.getline()、getline()、gets()函数的用法
- 安卓Textview的getLineCount返回0
- C++中cin、cin.get()、cin.getline()、getline()、gets()、getchar()、scanf()等函数的用法
- C/C++cin.get、cin.getline、getline、gets、getchar
- 关于cin.getline()和getline()的探讨
- cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- 【转】cin、cin.get、cin.getline之间的区别
- c++中 cin、cin.get()、cin.getline()、getline()、gets()函数的用法