Exclui espaços em branco após determinado caractere [duplicado]

0

Estou usando este comando sed para excluir a palavra --More-- :

sed 's/--More--\s*/ /' tabladetallada.dat

o arquivo original é assim:

Device ID: BIOTERIO
  IP address: 148.228.83.189
Interface: GigabitEthernet1/0/6,  Port ID (outgoing port): GigabitEthernet0/1
 --More--         Device ID: N7K-LAN(JAF1651ANDL)
  IP address: 148.228.4.192
Interface: GigabitEthernet1/0/1,  Port ID (outgoing port): Ethernet7/23
Device ID: LAB_PESADO
  IP address: 148.228.131.130
Interface: GigabitEthernet1/0/11,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.131.130
Device ID: Arquitectura_Salones
  IP address: 148.228.135.61
Interface: GigabitEthernet1/0/9,  Port ID (outgoing port): GigabitEthernet0/49
  IP address: 148.228.135.61
Device ID: CIVIL_253
  IP address: 148.228.132.253
 --More--         Interface: GigabitEthernet1/0/4,  Port ID (outgoing port): GigabitEthernet1/0/52
  IP address: 148.228.132.253
Device ID: Arquitectura
  IP address: 148.228.134.253
Interface: GigabitEthernet1/0/3,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.134.253
Device ID: ING_CIVIL
  IP address: 148.228.133.251
Interface: GigabitEthernet1/0/7,  Port ID (outgoing port): GigabitEthernet0/2
  IP address: 148.228.133.251
Device ID: ING_CIVIL_DIR
  IP address: 148.228.4.188
Interface: GigabitEthernet1/0/10,  Port ID (outgoing port): GigabitEthernet0/2
Device ID: Ingenieria_Posgrado
  IP address: 148.228.137.253
Interface: GigabitEthernet1/0/8,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.137.253
Device ID: Biblio_Barragan
  IP address: 148.228.136.61
Interface: GigabitEthernet1/0/2,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.136.61
Device ID: Electronica_Edif_3
 --More--           IP address: 148.228.130.253
Interface: GigabitEthernet1/0/5,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.130.253

Depois que a palavra é excluída, os espaços em branco depois dela ainda estão lá Como posso deletá-los?

Device ID: BIOTERIO
  IP address: 148.228.83.189
Interface: GigabitEthernet1/0/6,  Port ID (outgoing port): GigabitEthernet0/1
           Device ID: N7K-LAN(JAF1651ANDL)
  IP address: 148.228.4.192
Interface: GigabitEthernet1/0/1,  Port ID (outgoing port): Ethernet7/23
Device ID: LAB_PESADO
  IP address: 148.228.131.130
Interface: GigabitEthernet1/0/11,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.131.130
Device ID: Arquitectura_Salones
  IP address: 148.228.135.61
Interface: GigabitEthernet1/0/9,  Port ID (outgoing port): GigabitEthernet0/49
  IP address: 148.228.135.61
Device ID: CIVIL_253
  IP address: 148.228.132.253
           Interface: GigabitEthernet1/0/4,  Port ID (outgoing port): GigabitEthernet1/0/52
  IP address: 148.228.132.253
Device ID: Arquitectura
  IP address: 148.228.134.253
Interface: GigabitEthernet1/0/3,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.134.253
Device ID: ING_CIVIL
  IP address: 148.228.133.251
Interface: GigabitEthernet1/0/7,  Port ID (outgoing port): GigabitEthernet0/2
  IP address: 148.228.133.251
Device ID: ING_CIVIL_DIR
  IP address: 148.228.4.188
Interface: GigabitEthernet1/0/10,  Port ID (outgoing port): GigabitEthernet0/2
Device ID: Ingenieria_Posgrado
  IP address: 148.228.137.253
Interface: GigabitEthernet1/0/8,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.137.253
Device ID: Biblio_Barragan
  IP address: 148.228.136.61
Interface: GigabitEthernet1/0/2,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.136.61
Device ID: Electronica_Edif_3
             IP address: 148.228.130.253
Interface: GigabitEthernet1/0/5,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.130.253
    
por Cesar Alejandro Villegas Yepez 01.03.2017 / 16:51

2 respostas

4

A substituição deve parecer

s/--More-- */ /

ou

s/--More--[[:blank:]]*/ /

sed não sabe sobre \s para "espaço", mas trata-o como um literal s .

␣* (espaço + * ) corresponderá a zero ou mais espaços.

[[:blank:]]* corresponderá a zero ou mais espaços ou tabulações.

    
por 01.03.2017 / 16:53
0

Você pode usar sed da seguinte forma:

sed 's/--More--[[:space:]]//g' file
    
por 01.03.2017 / 17:10

Tags