명령 출력에서 ​​줄 제거

명령 출력에서 ​​줄 제거

다음 명령을 실행 중입니다. 명령의 출력을 파일에 저장해야 하지만 헤더는 없습니다.

나는 시도했습니다 - yarn top | tail -n +8( yarn topLinux와 마찬가지로 top3초마다 새로 고쳐지고 출력을 반복합니다)

yarn top
YARN top - 00:47:26, up 24d, 2:49, 0 active users, queue(s): root
NodeManager(s): 7 total, 7 active, 0 unhealthy, 0 decommissioned, 0 lost, 0 rebooted
Queue(s) Applications: 8 running, 111 submitted, 15 pending, 111 completed, 5 killed, 5 failed
Queue(s) Mem(GB): 100 available, 20 allocated, 0 pending, 0 reserved
Queue(s) VCores: 200 available, 2 allocated, 0 pending, 0 reserved

                  APPLICATIONID USER             TYPE      QUEUE   #CONT  #RCONT  VCORES RVCORES     MEM    RMEM  VCORESECS    MEMSECS %PROGR       TIME NAME
application_1484661449412_1115434 papp     mapreduce    default       3       0       3       0     16G      0G         28        172   5.00   00:00:00 EdmHdpIf-SRI
application_1484661449412_1115420 papp     mapreduce    default       2       0       2       0     12G      0G         86        545  95.00   00:00:00 oozie:launch
application_1484661449412_1115433 eapp     mapreduce       eapp       2       0       2       0     12G      0G         23        160   5.00   00:00:00 oozie:launch
application_1484661449412_1115386 eapp     mapreduce       eapp       2       0       2       0     12G      0G        250       1524  95.00   00:00:02 oozie:launch

예상 출력

application_1484661449412_1115434 papp     mapreduce    default       3       0       3       0     16G      0G         28        172   5.00   00:00:00 EdmHdpIf-SRI
application_1484661449412_1115420 papp     mapreduce    default       2       0       2       0     12G      0G         86        545  95.00   00:00:00 oozie:launch
application_1484661449412_1115433 eapp     mapreduce       eapp       2       0       2       0     12G      0G         23        160   5.00   00:00:00 oozie:launch
application_1484661449412_1115386 eapp     mapreduce       eapp       2       0       2       0     12G      0G        250       1524  95.00   00:00:02 oozie:launch

답변1

이 경우 grep을 사용하는 것이 가장 효과적입니다.

1) yarn top | grep -A20 APPLICATIONID

- 문자열을 일치시킨 후 데이터를 인쇄합니다.

20- (A) 문자열을 일치시킨 후 인쇄할 라인 수

[gc13@oc1245342277 sh]$ cat text1 
YARN top - 00:47:26, up 24d, 2:49, 0 active users, queue(s): root
NodeManager(s): 7 total, 7 active, 0 unhealthy, 0 decommissioned, 0 lost, 0 rebooted
Queue(s) Applications: 8 running, 111 submitted, 15 pending, 111 completed, 5 killed, 5 failed
Queue(s) Mem(GB): 100 available, 20 allocated, 0 pending, 0 reserved
Queue(s) VCores: 200 available, 2 allocated, 0 pending, 0 reserved

                  APPLICATIONID USER             TYPE      QUEUE   #CONT  #RCONT  VCORES RVCORES     MEM    RMEM  VCORESECS    MEMSECS %PROGR       TIME NAME
application_1484661449412_1115434 papp     mapreduce    default       3       0       3       0     16G      0G         28        172   5.00   00:00:00 EdmHdpIf-SRI
application_1484661449412_1115420 papp     mapreduce    default       2       0       2       0     12G      0G         86        545  95.00   00:00:00 oozie:launch
application_1484661449412_1115433 eapp     mapreduce       eapp       2       0       2       0     12G      0G         23        160   5.00   00:00:00 oozie:launch
application_1484661449412_1115386 eapp     mapreduce       eapp       2       0       2       0     12G      0G        250       1524  95.00   00:00:02 oozie:launch
[gc13@oc1245342277 sh]$ 
[gc13@oc1245342277 sh]$ 
[gc13@oc1245342277 sh]$ 
[gc13@oc1245342277 sh]$ 
[gc13@oc1245342277 sh]$ cat text1 | grep -A20 APPLICATIONID
                  APPLICATIONID USER             TYPE      QUEUE   #CONT  #RCONT  VCORES RVCORES     MEM    RMEM  VCORESECS    MEMSECS %PROGR       TIME NAME
application_1484661449412_1115434 papp     mapreduce    default       3       0       3       0     16G      0G         28        172   5.00   00:00:00 EdmHdpIf-SRI
application_1484661449412_1115420 papp     mapreduce    default       2       0       2       0     12G      0G         86        545  95.00   00:00:00 oozie:launch
application_1484661449412_1115433 eapp     mapreduce       eapp       2       0       2       0     12G      0G         23        160   5.00   00:00:00 oozie:launch
application_1484661449412_1115386 eapp     mapreduce       eapp       2       0       2       0     12G      0G        250       1524  95.00   00:00:02 oozie:launch
[gc13@oc1245342277 sh]$ 

관련 정보