Bloco de ordenação de linhas que correspondem apenas ao primeiro

1

Eu tenho um arquivo de saída do Nmap como este:

Nmap scan report for AAAAAAAAAAAAAAAAAA.akamaitechnologies.com (IP)
Host is up, received user-set (0.027s latency).
Scanned at 2016-10-09 14:43:24 CEST for 15s
PORT    STATE SERVICE  REASON         VERSION
443/tcp open  ssl/http syn-ack ttl 59 AkamaiGHost (Akamai's HTTP Acceleration/Mirror service)
Nmap scan report for AAAAAAAAAAAAAAAAAA.akamaitechnologies.com (IP)
Host is up, received user-set.
Scanned at 2016-10-09 14:43:21 CEST for 2s
PORT     STATE    SERVICE      REASON      VERSION
2222/tcp filtered EtherNetIP-1 no-response
Nmap scan report for CCCCCCCCCCC. googleusercontent.com (IP)
Host is up, received user-set (0.15s latency).
Scanned at 2016-10-09 14:43:21 CEST for 3s
PORT     STATE SERVICE REASON         VERSION
2222/tcp open  ssh     syn-ack ttl 55 ProFTPD mod_sftp 0.9.9 (protocol 2.0)
Nmap scan report for BBBBBBBBBBBBBBBBBBB
Host is up, received user-set (0.16s latency).
Scanned at 2016-10-09 14:43:21 CEST for 3s
PORT     STATE SERVICE REASON         VERSION
2222/tcp open  ssh     syn-ack ttl 51 ProFTPD mod_sftp 0.9.9 (protocol 2.0)
Nmap scan report for AAAAAAAAAAAAAAAAAA.akamaitechnologies.com (IP)
Host is up, received user-set (0.027s latency).
Scanned at 2016-10-09 14:43:24 CEST for 15s
PORT    STATE SERVICE  REASON         VERSION
443/tcp open  ssl/http syn-ack ttl 59 AkamaiGHost (Akamai's HTTP Acceleration/Mirror service)

Eu gostaria de classificar esse arquivo para cada bloco de 5 linhas usando como correspondência de classificação "relatório de varredura do Nmap para", a saída deve ser:

Nmap scan report for AAAAAAAAAAAAAAAAAA.akamaitechnologies.com (IP)
Host is up, received user-set (0.027s latency).
Scanned at 2016-10-09 14:43:24 CEST for 15s
PORT    STATE SERVICE  REASON         VERSION
443/tcp open  ssl/http syn-ack ttl 59 AkamaiGHost (Akamai's HTTP Acceleration/Mirror service)
Nmap scan report for AAAAAAAAAAAAAAAAAA.akamaitechnologies.com (IP)
Host is up, received user-set.
Scanned at 2016-10-09 14:43:21 CEST for 2s
PORT     STATE    SERVICE      REASON      VERSION
2222/tcp filtered EtherNetIP-1 no-response
Nmap scan report for BBBBBBBBBBBBBBBBBBB
Host is up, received user-set (0.16s latency).
Scanned at 2016-10-09 14:43:21 CEST for 3s
PORT     STATE SERVICE REASON         VERSION
2222/tcp open  ssh     syn-ack ttl 51 ProFTPD mod_sftp 0.9.9 (protocol 2.0)
Nmap scan report for CCCCCCCCCCC. googleusercontent.com (IP)
Host is up, received user-set (0.15s latency).
Scanned at 2016-10-09 14:43:21 CEST for 3s
PORT     STATE SERVICE REASON         VERSION
2222/tcp open  ssh     syn-ack ttl 55 ProFTPD mod_sftp 0.9.9 (protocol 2.0)

uma solução usando comandos unix é apreciada.

    
por heisen 09.10.2016 / 15:33

1 resposta

1

Para cada bloco de cinco linhas de concatenação de linhas (por exemplo, usar um caracter ascii baixo como \x02 , que provavelmente não ocorrerá em sua entrada - supondo que suas ferramentas o suportam), classifique no primeiro campo e restaure as novas linhas:

sed 'N;N;N;N;s/\n/\x02/g' infile | sort -t$'' -k1,1 | tr '' '\n'
    
por 09.10.2016 / 15:58