두 패턴 사이의 선을 추출하여 다른 파일에 저장하는 방법

두 패턴 사이의 선을 추출하여 다른 파일에 저장하는 방법

다음 파일이 있다고 가정해 보겠습니다.

rrows 35 cols 51  spin 2 %band5 efermi=0.012538
0.004352  0.004317  0.004213  0.004047  0.003828  0.003570  0.003291  0.003011
0.002754  0.002544  0.002408  0.002376  0.002478  0.002742  0.003200  0.003882
0.004818  0.006034  0.007560  0.009420  0.011637  0.014209  0.017205  0.020617
0.024458  0.028717  0.024458  0.020617  0.017205  0.014209  0.011637  0.009420
0.007560  0.006034  0.004818  0.003882  0.003200  0.002742  0.002478  0.002376
0.002408  0.002544  0.002754  0.003011  0.003291  0.003570  0.003828  0.004047
0.004213  0.004317  0.004352
0.004339  0.004087  0.003978  0.003805  0.003576  0.003305  0.003009  0.002708
0.002425  0.002184  0.002011  0.001934  0.001979  0.002172  0.002538  0.003096
0.003855  0.004930  0.006453  0.008311  0.010524  0.013114  0.016097  0.019488
0.023300  0.027520  0.023300  0.019488  0.016096  0.013113  0.010523  0.008310
0.006452  0.004928  0.003856  0.003097  0.002539  0.002173  0.001979  0.001934
0.002012  0.002185  0.002426  0.002709  0.003009  0.003305  0.003576  0.003805
0.003979  0.004088  0.004339
rrows 35 cols 51  spin 2 %band7 efermi=0.012538
-0.083687 -0.083837 -0.084283 -0.085015 -0.086017 -0.087265 -0.088733 -0.090386
-0.092190 -0.094103 -0.096082 -0.098082 -0.100055 -0.101950 -0.103713 -0.105283
-0.106592 -0.107556 -0.108073 -0.108026 -0.107336 -0.106094 -0.106755 -0.107283
-0.106405 -0.108146 -0.106406 -0.107280 -0.106757 -0.106094 -0.107335 -0.108024
-0.108070 -0.107553 -0.106589 -0.105280 -0.103710 -0.101947 -0.100052 -0.098079
-0.096079 -0.094100 -0.092187 -0.090384 -0.088731 -0.087264 -0.086016 -0.085014
-0.084283 -0.083837 -0.083687
-0.085767 -0.085905 -0.086315 -0.086988 -0.087910 -0.089061 -0.090418 -0.091950
-0.093626 -0.095410 -0.097264 -0.099147 -0.101017 -0.102829 -0.104540 -0.106099
-0.107455 -0.108548 -0.109305 -0.109631 -0.109407 -0.108549 -0.107204 -0.105849
-0.106353 -0.108175 -0.106354 -0.105851 -0.107205 -0.108549 -0.109406 -0.109630
-0.109304 -0.108546 -0.107453 -0.106097 -0.104537 -0.102827 -0.101015 -0.099145
-0.097262 -0.095409 -0.093625 -0.091949 -0.090417 -0.089060 -0.087909 -0.086987
-0.086314 -0.085905 -0.085767
rrows 35 cols 51  spin 2 %band9 efermi=0.012538
-0.061113 -0.061436 -0.062390 -0.063941 -0.066032 -0.068592 -0.071540 -0.074790
-0.078249 -0.081826 -0.085425 -0.088945 -0.092274 -0.095281 -0.097398 -0.099381
-0.100501 -0.101364 -0.104053 -0.105697 -0.106070 -0.105020 -0.103471 -0.105104
-0.106376 -0.107276 -0.106378 -0.105107 -0.103474 -0.105024 -0.106076 -0.105700
-0.104061 -0.101373 -0.100495 -0.099380 -0.097396 -0.095273 -0.092266 -0.088937
-0.085418 -0.081819 -0.078243 -0.074784 -0.071535 -0.068587 -0.066028 -0.063938
-0.062388 -0.061435 -0.061113
-0.067212 -0.067480 -0.068275 -0.069570 -0.071323 -0.073481 -0.075980 -0.078749
-0.081714 -0.084796 -0.087914 -0.090982 -0.093903 -0.096572 -0.098857 -0.100599
-0.101611 -0.101720 -0.104006 -0.106581 -0.107862 -0.107418 -0.105241 -0.104975
-0.106487 -0.107607 -0.106490 -0.104977 -0.105243 -0.107422 -0.107868 -0.106588
-0.104013 -0.101715 -0.101604 -0.100592 -0.098850 -0.096565 -0.093896 -0.090975
-0.087908 -0.084790 -0.081708 -0.078744 -0.075975 -0.073477 -0.071320 -0.069567
-0.068273 -0.067479 -0.067212

도착하다

파일 1:

0.004352  0.004317  0.004213  0.004047  0.003828  0.003570  0.003291  0.003011
0.002754  0.002544  0.002408  0.002376  0.002478  0.002742  0.003200  0.003882
0.004818  0.006034  0.007560  0.009420  0.011637  0.014209  0.017205  0.020617
0.024458  0.028717  0.024458  0.020617  0.017205  0.014209  0.011637  0.009420
0.007560  0.006034  0.004818  0.003882  0.003200  0.002742  0.002478  0.002376
0.002408  0.002544  0.002754  0.003011  0.003291  0.003570  0.003828  0.004047
0.004213  0.004317  0.004352
0.004339  0.004087  0.003978  0.003805  0.003576  0.003305  0.003009  0.002708
0.002425  0.002184  0.002011  0.001934  0.001979  0.002172  0.002538  0.003096
0.003855  0.004930  0.006453  0.008311  0.010524  0.013114  0.016097  0.019488
0.023300  0.027520  0.023300  0.019488  0.016096  0.013113  0.010523  0.008310
0.006452  0.004928  0.003856  0.003097  0.002539  0.002173  0.001979  0.001934
0.002012  0.002185  0.002426  0.002709  0.003009  0.003305  0.003576  0.003805
0.003979  0.004088  0.004339

파일 2:

-0.083687 -0.083837 -0.084283 -0.085015 -0.086017 -0.087265 -0.088733 -0.090386
-0.092190 -0.094103 -0.096082 -0.098082 -0.100055 -0.101950 -0.103713 -0.105283
-0.106592 -0.107556 -0.108073 -0.108026 -0.107336 -0.106094 -0.106755 -0.107283
-0.106405 -0.108146 -0.106406 -0.107280 -0.106757 -0.106094 -0.107335 -0.108024
-0.108070 -0.107553 -0.106589 -0.105280 -0.103710 -0.101947 -0.100052 -0.098079
-0.096079 -0.094100 -0.092187 -0.090384 -0.088731 -0.087264 -0.086016 -0.085014
-0.084283 -0.083837 -0.083687
-0.085767 -0.085905 -0.086315 -0.086988 -0.087910 -0.089061 -0.090418 -0.091950
-0.093626 -0.095410 -0.097264 -0.099147 -0.101017 -0.102829 -0.104540 -0.106099
-0.107455 -0.108548 -0.109305 -0.109631 -0.109407 -0.108549 -0.107204 -0.105849
-0.106353 -0.108175 -0.106354 -0.105851 -0.107205 -0.108549 -0.109406 -0.109630
-0.109304 -0.108546 -0.107453 -0.106097 -0.104537 -0.102827 -0.101015 -0.099145
-0.097262 -0.095409 -0.093625 -0.091949 -0.090417 -0.089060 -0.087909 -0.086987
-0.086314 -0.085905 -0.085767

등.

추신: rrows 35 cols 51 spin 2 %band9 efermi=0.012538한 ​​행. 두 사이의 행/열을 추출하고 싶습니다.rrows 35 cols 51 spin 2 %band9 efermi=0.012538 rrows 35 cols 51 spin 2 %band10 efermi=0.012538

나는 다음과 같은 명령을 작성했습니다.

~$ awk '{for(i=2;i<=NF;i++) {awk 'NR >= i && NR <= i+2' <bnds.fe >out_$i'};printf out_$i}'

실패한. 이 문제를 해결하는 데 도움을 주실 수 있나요?

감사해요

답변1

사용 awk:

< input awk '/^rrows/ {i++; next} {print >> "file"i}'

관련 정보