Remover linhas da saída do comando

0

Estou correndo abaixo do comando; Eu preciso armazenar a saída do comando em um arquivo, mas sem cabeçalhos.

Eu tentei - yarn top | tail -n +8 (como yarn top funciona como o Linux top que é atualizado a cada 3 segundos e repete a saída)

Por favor, informe como posso conseguir isso.

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

Saída esperada

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
    
por chhaya vishwakarma 10.02.2017 / 18:06

1 resposta

1

Usando o grep, funciona melhor neste caso:

1) yarn top | grep -A20 APPLICATIONID

A - Imprimir dados após a correspondência da string

20 - número de linhas a serem impressas após (A) string correspondente

[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]$ 

Espero que isso ajude.

    
por 10.02.2017 / 21:24