-2

I have a text file like this:

Device ID: BIOTERIO
  IP address: 148.228.83.000
Interface: GigabitEthernet1/0/6,  Port ID (outgoing port): GigabitEthernet0/1
 --More--         Device ID: N7K-LAN(JAF1651ANDL)
  IP address: 148.228.4.000
Interface: GigabitEthernet1/0/1,  Port ID (outgoing port): Ethernet7/23
Device ID: LAB_PESADO
  IP address: 148.228.131.000
Interface: GigabitEthernet1/0/11,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.131.000
Device ID: Arquitectura_Salones
  IP address: 148.228.135.00
Interface: GigabitEthernet1/0/9,  Port ID (outgoing port): GigabitEthernet0/49
  IP address: 148.228.135.00
Device ID: CIVIL_253
  IP address: 148.228.132.000
 --More--         Interface: GigabitEthernet1/0/4,  Port ID (outgoing port): GigabitEthernet1/0/52
  IP address: 148.228.132.000
Device ID: Arquitectura
  IP address: 148.228.134.000
Interface: GigabitEthernet1/0/3,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.134.000
Device ID: ING_CIVIL
  IP address: 148.228.133.000
Interface: GigabitEthernet1/0/7,  Port ID (outgoing port): GigabitEthernet0/2
  IP address: 148.228.133.000
Device ID: ING_CIVIL_DIR
  IP address: 148.228.4.000
Interface: GigabitEthernet1/0/10,  Port ID (outgoing port): GigabitEthernet0/2
Device ID: Ingenieria_Posgrado
  IP address: 148.228.137.000
Interface: GigabitEthernet1/0/8,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.137.000
Device ID: Biblio_Barragan
  IP address: 148.228.136.00
Interface: GigabitEthernet1/0/2,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.136.00
Device ID: Electronica_Edif_3
 --More--           IP address: 148.228.130.000
Interface: GigabitEthernet1/0/5,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.130.000

I would like to delete the word --More-- so the text file looks like this:

Device ID: BIOTERIO
  IP address: 148.228.83.000
Interface: GigabitEthernet1/0/6,  Port ID (outgoing port): GigabitEthernet0/1
 Device ID: N7K-LAN(JAF1651ANDL)
  IP address: 148.228.4.000
Interface: GigabitEthernet1/0/1,  Port ID (outgoing port): Ethernet7/23
Device ID: LAB_PESADO
  IP address: 148.228.131.000
Interface: GigabitEthernet1/0/11,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.131.000
Device ID: Arquitectura_Salones
  IP address: 148.228.135.00
Interface: GigabitEthernet1/0/9,  Port ID (outgoing port): GigabitEthernet0/49
  IP address: 148.228.135.00
Device ID: CIVIL_253
  IP address: 148.228.132.000
 Interface: GigabitEthernet1/0/4,  Port ID (outgoing port): GigabitEthernet1/0/52
  IP address: 148.228.132.000
Device ID: Arquitectura
  IP address: 148.228.134.000
Interface: GigabitEthernet1/0/3,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.134.000
Device ID: ING_CIVIL
  IP address: 148.228.133.000
Interface: GigabitEthernet1/0/7,  Port ID (outgoing port): GigabitEthernet0/2
  IP address: 148.228.133.000
Device ID: ING_CIVIL_DIR
  IP address: 148.228.4.000
Interface: GigabitEthernet1/0/10,  Port ID (outgoing port): GigabitEthernet0/2
Device ID: Ingenieria_Posgrado
  IP address: 148.228.137.000
Interface: GigabitEthernet1/0/8,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.137.000
Device ID: Biblio_Barragan
  IP address: 148.228.136.00
Interface: GigabitEthernet1/0/2,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.136.00
Device ID: Electronica_Edif_3
 IP address: 148.228.130.000
Interface: GigabitEthernet1/0/5,  Port ID (outgoing port): GigabitEthernet0/1
  IP address: 148.228.130.000

I have tried using sed -e 's/\<--More-->//g' tabladetallada.dat, but it didn't work

Any help? Thanks in advance.

UPDATE: using sed 's/--More--\s*/ /' the word is deleted but the spaces are still there, like this:

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
  • As simple as grep -vi 'more' yourfile.txt – Valentin Bajrami Feb 28 '17 at 17:25
1
sed 's/--More-- */ /' file

you don't need to escape anything. * means any number of the preceeding character, which here is a space. If there might be tabs too, you can use

sed 's/--More--\s*/ /' file

In GNU sed or

sed 's/--More--[[:blank:]]*/ /' file
  • Hi @Zanna, how can I delete also the whitespaces – Cesar Alejandro Villegas Yepez Mar 1 '17 at 15:36
  • @CesarAlejandroVillegasYepez my answer in theory removes all whitespace and replaces with a single space. You just reminded me to edit it though. Try again? If you don't want the space, remove the space between the last two delimiters (but the alignment of your file will be off then I feel) – Zanna Mar 1 '17 at 16:11
0

you can use sed as follows:

sed 's/--More--//g' file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.