Interdire l'affichage d'un caractere

Résolu
chrisee Messages postés 212 Statut Membre -  
chrisee Messages postés 212 Statut Membre -
Bonsoir,
J'ai un script,mais il y a un petit truc que je n'arrive à faire.en faisant un reverse lookup

host 192.168.1.2|cut -d " " -f 5

J'obtiens "nomHote.nomDom.cd." Et je ne peux pas faire un ping sur un nom de domain terminé par un "." comme c'est le cas,comment puis-je faire pour n'obtenir que "nomHote.nomDom.cd" sans le "." à la fin,j'ai essayé avec plusieurs technique même les expressions regulieres mais,ça ne resout pas le problème du "." à la fin,merci d'avance pour votre aide.

1 réponse

  1. zipe31 Messages postés 34620 Date d'inscription   Statut Contributeur Dernière intervention   6 501
     
    Salut,

    $ var=$(host 192.168.10.58|cut -d " " -f 5)

    $ echo "${var}"
    Mint-Qiana.localdomain.

    $ echo "${var%*.}"
    Mint-Qiana.localdomain

    $ ping "${var%*.}"
    PING Mint-Qiana.localdomain (192.168.10.58) 56(84) bytes of data.
    64 bytes from Mint-Qiana.localdomain (192.168.10.58): icmp_seq=1 ttl=64 time=0.022 ms
    64 bytes from Mint-Qiana.localdomain (192.168.10.58): icmp_seq=2 ttl=64 time=0.031 ms
    64 bytes from Mint-Qiana.localdomain (192.168.10.58): icmp_seq=3 ttl=64 time=0.031 ms
    64 bytes from Mint-Qiana.localdomain (192.168.10.58): icmp_seq=4 ttl=64 time=0.031 ms

    --- Mint-Qiana.localdomain ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 2998ms
    rtt min/avg/max/mdev = 0.022/0.028/0.031/0.007 ms

    1
    1. chrisee Messages postés 212 Statut Membre 10
       
      Merci beucoup Zipe31 ,tu as résolu mon problème
      0