• [^] # Re: Ca marche. NON mais ou donc est-ce que ca coince ?

    Posté par . En réponse au message Pb d'extraction d'une url. Évalué à 1.

    Si je reproduis dans un terminal la manoeuvre exactement comme tu le dis, effectivement ça marche, mais je ne vois pas la différence de fond avec mon script
    Je me suis fait un fichier provht1 ne contenant que la ligne à chercher

    En utilisant :
    old=$(sed -n "$nlUM"p provurl1)
    sed -n "/$old/=" provht1

    Je trouve :

    old = http:\/\/www.geographiques.com\/spip\/article.php3?id_article=18
    provht1 = http://www.geographiques.com/spip/article.php3?id_article=18
    nbtrouv = 0

    Donc, chez moi, cela ne marche pas.
    Mais en allant plus loin dans le fichier provurl1, je constate :

    old = http:\/\/www.geographiques.com\/
    provht1 = http://www.geographiques.com/spip/article.php3?id_article=18
    nbtrouv = 1

    Intéressant, non ? Le pb serait dans spip/article.php3?id_article=18. Je deviens fou ! Bon maintenant je fais :
    $ old="http:\/\/www.geographiques.com\/spip\/article.php3?id_article=18"
    $ sed -n "/$old/=" provht1
    1
    et, bien sûr :
    $ old="http:\/\/www.geographiques.com\/spip"
    $ sed -n "/$old/=" provht1
    1
    $ old="http:\/\/www.geographiques.com\/ploutch"
    $ sed -n "/$old/=" provht1
    0
    Le pb serait dans la façon dont on se procure $old ?
    Par acquis de conscience, je me tape ça dans le terminal pour éliminer un problème lié à sh monscript.sh
    $ cat provht1
    http://www.geographiques.com/spip/article.php3?id_article=18
    $ old=$(sed -n 33p provurl1) # ligne 33 celle de l'url
    $ sed -n "/$old/=" provht1
    0 # grrh !
    $ old=$(sed -n 35p provurl1) # ligne 35 = http:\/\/www.geographiques.com\/
    $ sed -n "/$old/=" provht1
    1
    M'enfin. Incroyable cette histoire. Ca doit être un truc hyper évident. Tellement que je ne le vois pas :-(