Newsgroup: it.comp.os.linux.iniziare
Titolo: Manipolazione file con tr

Ciao,
vorrei modificare questa "manipolazione" del testo con il comando "tr" 
per permettere di mettere su una linea indirizzo ip e mac address.
Mi potete aiutare ?
Grazie
 
 
 
$ cat file.txt | sed '/^Host/d'
Nmap scan report for 10.24.59.1
MAC Address: 00:00:0C:07:AC:64 (Cisco Systems)
Nmap scan report for 10.24.59.2
MAC Address: 00:13:C4:A8:0A:BF (Cisco Systems)
Nmap scan report for 10.24.59.3
MAC Address: 00:13:C4:A8:0E:7F (Cisco Systems)
Nmap scan report for pippo.dominio.um (10.24.59.11)
MAC Address: 00:01:02:9D:C9:B3 (3com)
Nmap scan report for pluto.dominio.um (10.24.59.12)
MAC Address: C4:34:6B:24:79:1F (Unknown)
Nmap scan report for paperino.dominio.um (10.24.59.14)
MAC Address: 2C:59:E5:00:E4:22 (Hewlett Packard)
 
Risultato che vorrei ottenere:
 
Nmap scan report for 10.24.59.1 - MAC Address: 00:00:0C:07:AC:64 (Cisco 
Systems)
Nmap scan report for 10.24.59.2 - MAC Address: 00:13:C4:A8:0A:BF (Cisco 
Systems)
Nmap scan report for 10.24.59.3 - MAC Address: 00:13:C4:A8:0E:7F (Cisco 
Systems)
Nmap scan report for pippo.dominio.um (10.24.59.11) - MAC Address: 
00:01:02:9D:C9:B3 (3com)
Nmap scan report for pluto.dominio.um (10.24.59.12) - MAC Address: 
C4:34:6B:24:79:1F (Unknown)
Nmap scan report for paperino.dominio.um (10.24.59.14) - MAC Address: 
2C:59:E5:00:E4:22 (Hewlett Packard)
 
 

 Mi potete aiutare ?
 
  A viene più facile usando awk:
 
[alessandro@posta-k3 ~ ]$ cat /tmp/a
Host: pippo
Nmap scan report for 10.24.59.1
MAC Address: 00:00:0C:07:AC:64 (Cisco Systems)
Host: pluto
Nmap scan report for 10.24.59.2
MAC Address: 00:13:C4:A8:0A:BF (Cisco Systems)
Host: qui
Nmap scan report for 10.24.59.3
MAC Address: 00:13:C4:A8:0E:7F (Cisco Systems)
Host: quo
Nmap scan report for pippo.dominio.um (10.24.59.11)
MAC Address: 00:01:02:9D:C9:B3 (3com)
Host: qua
Nmap scan report for pluto.dominio.um (10.24.59.12)
MAC Address: C4:34:6B:24:79:1F (Unknown)
Host: paperoga
Nmap scan report for paperino.dominio.um (10.24.59.14)
MAC Address: 2C:59:E5:00:E4:22 (Hewlett Packard)
[alessandro@posta-k3 ~ ]$ awk '($1 !~ /^Host/) {printf "%s - ", $0 ; getline
; print }' /tmp/a
Nmap scan report for 10.24.59.1 - MAC Address: 00:00:0C:07:AC:64 (Cisco Systems)
Nmap scan report for 10.24.59.2 - MAC Address: 00:13:C4:A8:0A:BF (Cisco Systems)
Nmap scan report for 10.24.59.3 - MAC Address: 00:13:C4:A8:0E:7F (Cisco Systems)
Nmap scan report for pippo.dominio.um (10.24.59.11) - MAC Address:
00:01:02:9D:C9:B3 (3com)
Nmap scan report for pluto.dominio.um (10.24.59.12) - MAC Address:
C4:34:6B:24:79:1F (Unknown)
Nmap scan report for paperino.dominio.um (10.24.59.14) - MAC Address:
2C:59:E5:00:E4:22 (Hewlett Packard)
[alessandro@posta-k3 ~ ]$
 
 
  Ciao,
 
 
-- 
Alessandro Selli 
http://alessandro.route-add.net
 
AVVERTENZA: i messaggi inviati a "trappola" non mi arriveranno.
WARNING: messages sent to "trappola" will never reach me.

 ; print }' /tmp/a
 
Non trova la corrispondenza.
 
 
$ cat file.txt
Nmap scan report for 10.24.59.1
Host is up (0.0033s latency).
MAC Address: 00:00:0C:07:AC:64 (Cisco Systems)
Nmap scan report for 10.24.59.2
Host is up (0.0037s latency).
MAC Address: 00:13:C4:A8:0A:BF (Cisco Systems)
Nmap scan report for 10.24.59.3
Host is up (0.0032s latency).
MAC Address: 00:13:C4:A8:0E:7F (Cisco Systems)
Nmap scan report for docarchivio.ofc (10.24.59.11)
Host is up (-0.10s latency).
MAC Address: 00:01:02:9D:C9:B3 (3com)
Nmap scan report for anouk.ofc (10.24.59.12)
Host is up (-0.092s latency).
MAC Address: C4:34:6B:24:79:1F (Unknown)
 
 
 
$ awk '($1 !~ /^Host/) {printf "%s - ", $0 ; getline; print }' file.txt
Nmap scan report for 10.24.59.1 - Host is up (0.0033s latency).
MAC Address: 00:00:0C:07:AC:64 (Cisco Systems) - Nmap scan report for 
10.24.59.2
MAC Address: 00:13:C4:A8:0A:BF (Cisco Systems) - Nmap scan report for 
10.24.59.3
MAC Address: 00:13:C4:A8:0E:7F (Cisco Systems) - Nmap scan report for 
docarchivio.ofc (10.24.59.11)
MAC Address: 00:01:02:9D:C9:B3 (3com) - Nmap scan report for anouk.ofc 
(10.24.59.12)
MAC Address: C4:34:6B:24:79:1F (Unknown) - MAC Address: 
C4:34:6B:24:79:1F (Unknown)
 
Sbaglio io qualcosa?
 
Ma se volessi mettere il risultato su una riga simile a questa?
 
Nmap scan report for 10.24.59.1 - Host is up (0.0033s latency). - MAC 
Address: 00:00:0C:07:AC:64 (Cisco Systems)
 
Così non funzionerebbe:
 
awk '{printf "%s - ", $0 ; getline; print }' file.txt
Nmap scan report for 10.24.59.1 - Host is up (0.0033s latency).
MAC Address: 00:00:0C:07:AC:64 (Cisco Systems) - Nmap scan report for 
10.24.59.2
Host is up (0.0037s latency). - MAC Address: 00:13:C4:A8:0A:BF (Cisco 
Systems)
Nmap scan report for 10.24.59.3 - Host is up (0.0032s latency).
MAC Address: 00:13:C4:A8:0E:7F (Cisco Systems) - Nmap scan report for 
docarchivio.ofc (10.24.59.11)
Host is up (-0.10s latency). - MAC Address: 00:01:02:9D:C9:B3 (3com)
Nmap scan report for anouk.ofc (10.24.59.12) - Host is up (-0.092s latency).
MAC Address: C4:34:6B:24:79:1F (Unknown) - MAC Address: 
