我想将此文本文件分成3个文本文件,每个段落组成一个文本文件。(我的操作系统是ubuntu12.04)
输入值
2008 2 2 1120 31.2长34.031 48.515 16.7 INS 5 0.3 4.0LINS 1
GAP = 145 0.67 4.1 2.9 6.6 0.2283E-01 -0.1718E + 00 0.1289E + 02E
动作:UPD 08-12-28 13:25 OP:moh状态:ID:20080202112031 L I
2008-02-02-1120-39S.IN ____ 006 6
STAT SP IPHASW D HRMM SECON CODA AMPLIT PERI AZIMU VELO AIN AR TRES W DIS CAZ7
SNGE BZ EPg 1120 57.69 91 0.0210 159318
SNGE BZ AML 1121 24.50 2880.9 0.55 159318
SHGR BZ EPN5 1121 5.17 52 -0.0510 215173
GHVR BZ EPn 1121 10.84 52 0.3610 256 78
GHVR BZ ESg 1121 43.50 91 -0.0210 256 78
CHTH BZ EPn 1121 18.26 52 0.1210 317 48
CHTH BZ AML 1122 8.01 494.0 0.68 317 48
DAMV BZ EPn 1121 23.36 52 -0.49 9 362 60
DAMV BZ AML 1122 7.03 382.0 0.48 362 60
2008 211 1403 46.2长27.659 55.544 14.1 INS 4 0.1 4.0LINS 1
GAP = 171 0.38 1.7 1.2 3.3 -0.8271E-01 -0.3724E-01 0.4284E + 00E
2008-02-11-1403-37S.INSN__048 6
动作:NEW 08-12-28 13:25 OP:moh状态:ID:20080211140346 L I
STAT SP IPHASW D HRMM SECON CODA AMPLIT PERI AZIMU VELO AIN AR TRES W DIS CAZ7
BNDS BZ EPg 14 3 58.14 90 -0.0710 68.3 115
BNDS BN AML 14 4 26.39 8461.0 0.52 68.3 115
GHIR BZ EPn 14 4 26.40 52 0.0310 261 286
GHIR BN ESg 14 4 59.85 90 -0.0110 261286
GHIR BN AML 14 5 25.22 1122.4 0.56 261286
吉尔反洗钱14 5 43.83 769.3 0.64 261286
KRBR BZ EPn 14 4 29.25 52 -0.1110 284 24
KRBR BN ESg 14 5 6.28 90 0.0010 284 24
KRBR BN AML 14 5 18.89 552.4 0.64 284 24
KRBR BE AML 14 5 19.22 574.0 0.60 284 24
ZHSF BZ EPn 14 5 3.24 52 0.25 8 555 66
2008 213 2055 31.5长31.713 51.180 14.1 INS 9 0.5 4.2LINS 1
GAP = 127 1.21 4.6 6.5 9.6 0.7570E + 01 -0.1161E + 02 0.9944E + 01E
动作:UPD 08-12-28 13:25 OP:moh状态:ID:20080213205531 L I
2008-02-13-2054-59S.NSN ___ 048 6
STAT SP IPHASW D HRMM SECON CODA AMPLIT PERI AZIMU VELO AIN AR TRES W DIS CAZ7
NASN BZ EPg 2056 3.15 90 -0.6410 195 51
SHGR BZ EPg 2056 8.57 90 -0.3810 229282
SHGR BN AML 2056 49.27 2371.2 0.77 229282
SHGR BE AML 2056 51.00 2484.4 0.77 229282
GHVR BZ EPn 2056 18.39 52 1.0110 307 1
GHVR BE AML 2057 11.42 734.2 0.85 307 1
ASAO BZ EPn 2056 20.35 52 -0.36 9332341
ASAO BE ESg 2057 5.23 90 0.27 9 332341
ASAO BN AML 2057 15.86 723.3 0.64 332341
GHIR BZ EPn 2056 31.68 52 0.48 9418155
GHIR BN AML 2057 51.30 259.1 0.79 418155
DAMV BZ EPn 2056 33.90 52 -0.27 9 441 9
DAMV BN AML 2057 43.30 237.4 0.65 441 9
THKV BZ EPn 2056 37.71 52 0.33 8467357
THKV BE AML 2057 51.62 205.7 0.72 467357
ZNJK BZ EPn 2056 53.12 52 -0.35 7 596 338
BNDS BZ EPn 2057 3.72 52 -0.06 7680133
output1.txt
2008 2 2 1120 31.2长34.031 48.515 16.7 INS 5 0.3 4.0LINS 1
GAP = 145 0.67 4.1 2.9 6.6 0.2283E-01 -0.1718E + 00 0.1289E + 02E
动作:UPD 08-12-28 13:25 OP:moh状态:ID:20080202112031 L I
2008-02-02-1120-39S.IN ____ 006 6
STAT SP IPHASW D HRMM SECON CODA AMPLIT PERI AZIMU VELO AIN AR TRES W DIS CAZ7
SNGE BZ EPg 1120 57.69 91 0.0210 159318
SNGE BZ AML 1121 24.50 2880.9 0.55 159318
SHGR BZ EPN5 1121 5.17 52 -0.0510 215173
GHVR BZ EPn 1121 10.84 52 0.3610 256 78
GHVR BZ ESg 1121 43.50 91 -0.0210 256 78
CHTH BZ EPn 1121 18.26 52 0.1210 317 48
CHTH BZ AML 1122 8.01 494.0 0.68 317 48
DAMV BZ EPn 1121 23.36 52 -0.49 9 362 60
DAMV BZ AML 1122 7.03 382.0 0.48 362 60
output2.txt
2008 211 1403 46.2长27.659 55.544 14.1 INS 4 0.1 4.0LINS 1
GAP = 171 0.38 1.7 1.2 3.3 -0.8271E-01 -0.3724E-01 0.4284E + 00E
2008-02-11-1403-37S.INSN__048 6
动作:NEW 08-12-28 13:25 OP:moh状态:ID:20080211140346 L I
STAT SP IPHASW D HRMM SECON CODA AMPLIT PERI AZIMU VELO AIN AR TRES W DIS CAZ7
BNDS BZ EPg 14 3 58.14 90 -0.0710 68.3 115
BNDS BN AML 14 4 26.39 8461.0 0.52 68.3 115
GHIR BZ EPn 14 4 26.40 52 0.0310 261 286
GHIR BN ESg 14 4 59.85 90 -0.0110 261286
GHIR BN AML 14 5 25.22 1122.4 0.56 261286
吉尔反洗钱14 5 43.83 769.3 0.64 261286
KRBR BZ EPn 14 4 29.25 52 -0.1110 284 24
KRBR BN ESg 14 5 6.28 90 0.0010 284 24
KRBR BN AML 14 5 18.89 552.4 0.64 284 24
KRBR BE AML 14 5 19.22 574.0 0.60 284 24
ZHSF BZ EPn 14 5 3.24 52 0.25 8 555 66
output3.txt
2008 213 2055 31.5长31.713 51.180 14.1 INS 9 0.5 4.2LINS 1
GAP = 127 1.21 4.6 6.5 9.6 0.7570E + 01 -0.1161E + 02 0.9944E + 01E
动作:UPD 08-12-28 13:25 OP:moh状态:ID:20080213205531 L I
2008-02-13-2054-59S.NSN ___ 048 6
STAT SP IPHASW D HRMM SECON CODA AMPLIT PERI AZIMU VELO AIN AR TRES W DIS CAZ7
NASN BZ EPg 2056 3.15 90 -0.6410 195 51
SHGR BZ EPg 2056 8.57 90 -0.3810 229282
SHGR BN AML 2056 49.27 2371.2 0.77 229282
SHGR BE AML 2056 51.00 2484.4 0.77 229282
GHVR BZ EPn 2056 18.39 52 1.0110 307 1
GHVR BE AML 2057 11.42 734.2 0.85 307 1
ASAO BZ EPn 2056 20.35 52 -0.36 9332341
ASAO BE ESg 2057 5.23 90 0.27 9 332341
ASAO BN AML 2057 15.86 723.3 0.64 332341
GHIR BZ EPn 2056 31.68 52 0.48 9418155
GHIR BN AML 2057 51.30 259.1 0.79 418155
DAMV BZ EPn 2056 33.90 52 -0.27 9 441 9
DAMV BN AML 2057 43.30 237.4 0.65 441 9
THKV BZ EPn 2056 37.71 52 0.33 8467357
THKV BE AML 2057 51.62 205.7 0.72 467357
ZNJK BZ EPn 2056 53.12 52 -0.35 7 596 338
BNDS BZ EPn 2057 3.72 52 -0.06 7680133
最佳答案
我给您一个想法,只是一种方法:逐行迭代文件。
将row!=“”或row!='\ n'的所有行保存在缓冲区中:在这种情况下,将缓冲区保存在其他文件中。
buffer=""
id=0
cat test | \
while read row; do
#check row value, save in buffer
.....
cat buffer > fileName_${id}.txt
id=$((id+1))
done