- 论坛徽章:
- 32
|
本帖最后由 yestreenstars 于 2013-11-05 09:48 编辑
有固定周期的可以这样做,从你提供的数据来看,固定周期为3,所以可以这么做:- [root@localhost test]# ls
- sse.dat test.dat
- [root@localhost test]# head sse.dat test.dat
- ==> sse.dat <==
- atno 1 TW 1.0 1.0 1.0
- atno 6 TW 1.0 2.0 1.0
- atno 11 TW 1.0 1.0 1.0
- atno 1 TW 5.0 1.0 3.0
- atno 6 TW 5.0 2.0 3.0
- atno 11 TW 5.0 1.0 3.0
- ==> test.dat <==
- atno 2 TW 1.0 1.0 1.0
- atno 8 TW 1.0 2.0 1.0
- atno 23 TW 1.0 1.0 1.0
- atno 2 TW 5.0 1.0 3.0
- atno 8 TW 5.0 2.0 3.0
- atno 23 TW 5.0 1.0 3.0
- [root@localhost test]# awk '{s=s?s"\n"$0:$0}!(FNR%3){split(FILENAME,a,".");print s > a[1]"-"++b[FILENAME]"."a[2];s=""}' *
- [root@localhost test]# ls
- sse-1.dat sse-2.dat sse.dat test-1.dat test-2.dat test.dat
- [root@localhost test]# head sse-* test-*
- ==> sse-1.dat <==
- atno 1 TW 1.0 1.0 1.0
- atno 6 TW 1.0 2.0 1.0
- atno 11 TW 1.0 1.0 1.0
- ==> sse-2.dat <==
- atno 1 TW 5.0 1.0 3.0
- atno 6 TW 5.0 2.0 3.0
- atno 11 TW 5.0 1.0 3.0
- ==> test-1.dat <==
- atno 2 TW 1.0 1.0 1.0
- atno 8 TW 1.0 2.0 1.0
- atno 23 TW 1.0 1.0 1.0
- ==> test-2.dat <==
- atno 2 TW 5.0 1.0 3.0
- atno 8 TW 5.0 2.0 3.0
- atno 23 TW 5.0 1.0 3.0
- [root@localhost test]#
复制代码 |
|