• Re: sed : suppression de lignes

    From =?UTF-8?B?SsOpcsOpbXkgUHJlZ28=?=@21:1/5 to All on Fri Sep 9 20:00:02 2022
    Bonjour,

    et en échappant les "." ?

    genre:
    sed '/49\.7\.20/' /tmp/file.txt

    Jerem
    Le 09/09/2022 à 19:22, antoine.valmer a écrit :
    Bonjour à tous,
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022

    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."
    @+ et merci.
    A. Valmer


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From antoine.valmer@21:1/5 to All on Fri Sep 9 19:40:01 2022
    Bonjour à tous,
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022

    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."
    @+ et merci.
    A. Valmer

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hugues Larrive@21:1/5 to All on Fri Sep 9 20:00:02 2022
    This is an OpenPGP/MIME signed message (RFC 4880 and 3156) -----------------------5d796aea3e89c0147e97ee0461ec4a6d Content-Transfer-Encoding: quoted-printable
    Content-Type: text/plain;charset=utf-8

    ------- Original Message -------
    Le vendredi 9 septembre 2022 à 19:22, antoine.valmer <[email protected]> a écrit :






    Bonjour à tous,
    Bonjour,

    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022


    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."
    @+ et merci.
    A. Valmer

    Essayez avec grep :
    grep -v '49.7.20.' le_fichier.txt

    (-v, --invert-match sélectionner les lignes sans correspondance)

    @+
    Hugues
    -----------------------5d796aea3e89c0147e97ee0461ec4a6d
    Content-Type: application/pgp-keys; filename="publickey - [email protected] - 0xE9429B87.asc"; name="publickey - [email protected] - 0xE9429B87.asc"
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename="publickey - [email protected] - 0xE9429B87.asc"; name="publickey - [email protected] - 0xE9429B87.asc"

    LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgp4ak1FWUZFMWNSWUpLd1lCQkFI YVJ3OEJBUWRBWlB0M2dhekNrdHVzaXFla2gzcnNsM0FLV0lUaUR1VGEKWk9tZEhCWjBtb3pOSDJo c1lYSnlhWFpsUUhCdExtMWxJRHhvYkdGeWNtbDJaVUJ3YlM1dFpUN0Nqd1FRCkZnb0FJQVVDWUZF MzRRWUxDUWNJQXdJRUZRZ0tBZ1FXQWdFQUFoa0JBaHNEQWg0QkFDRUpFRnZWSk5jdgo0dmswRmlF RTZVS2JoNHIyQ0RlSDZZRkJXOVVrMXkvaStUUWpDQUQvYTNwQ0hBSStsT2o1NHVOVVNTU0MKTDE4 NjFQYjI4YWs2K2JvRnN6bnVHc0FCQVBVczh3QnJLQXZxZ0RWYXFZdVd6d1BjTXNnZWJ3U0huOER3 Cmp1SDV6VmdPempnRVlGRTFjUklLS3dZQkJBR1hWUUVGQVFFSFFPbDZ3OXNiR1lmZHZOeVVPb3pj cExiZgp0aW56SWMraDVicS9rMU91TXdVRkF3RUlCOEo0QkJnV0NBQUpCUUpnVVRmaEFoc01BQ0VK RUZ2VkpOY3YKNHZrMEZpRUU2VUtiaDRyMkNEZUg2WUZCVzlVazF5L2krVFRoUEFEOUZTNFlrcFR0 RXJWNDFPRTBBaTNYClIxNlcrT3REa1p3bTZRVTY0VnUzSmJvQkFMMURMQngxRExLRE5kclZhTUZ1 NGp4MXBZV0JqTEpVZ0xLegpzbDMzakRNTQo9NXVpVgotLS0tLUVORCBQR1AgUFVCTElDIEtFWSBC TE9DSy0tLS0tCg==
    -----------------------5d796aea3e89c0147e97ee0461ec4a6d--

    -----BEGIN PGP SIGNATURE-----
    Version: ProtonMail

    wnUEARYKAAYFAmMbfPQAIQkQW9Uk1y/i+TQWIQTpQpuHivYIN4fpgUFb1STX L+L5NN62AP9/hzSTPXIyHUFebFWlhgJMdLVCg/T81qm85ArN4Af2EAEA+uH2 hZFEW1z7tWwt3IKO4iokh30kte9tcWOXLj8X3Qs=
    =Elio
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Basile Starynkevitch@21:1/5 to antoine.valmer on Fri Sep 9 19:50:01 2022
    This is a multi-part message in MIME format.
    On 09/09/2022 19:22, antoine.valmer wrote:
    Bonjour à tous,
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022

    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."
    @+ et merci.
    A. Valmer


    Je suggère de lire avec attention la difficile documentation de sed, par exemple (en anglais) https://man7.org/linux/man-pages/man1/sed.1.html
    puis d'essayer peut-être

    sed '1,$/49.7.20/d'


    Bien sûr, *essayez cette commande sur des données _fictives_* d'abord.


    Et je cherche des partenaires intéressés par RefPerSys en http://refpersys.org/

    Librement

    --
    Basile Starynkevitch<[email protected]>
    (only mine opinions / les opinions sont miennes uniquement)
    92340 Bourg-la-Reine, France
    web page: starynkevitch.net/Basile/

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 09/09/2022 19:22, antoine.valmer
    wrote:<br>
    </div>
    <blockquote type="cite"
    cite="mid:[email protected]">
    <pre class="moz-quote-pre" wrap="">Bonjour à tous,
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022

    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."
    @+ et merci.
    A. Valmer</pre>
    </blockquote>
    <p><br>
    </p>
    <p>Je suggère de lire avec attention la difficile documentation de <font
    face="monospace">sed</font>, par exemple (en anglais) <a
    moz-do-not-send="true"
    href="https://man7.org/linux/man-pages/man1/sed.1.html"
    class="moz-txt-link-freetext">https://man7.org/linux/man-pages/man1/sed.1.html</a>
    puis d'essayer peut-être</p>
    <p><font face="monospace">sed '1,$/49.7.20/d'</font></p>
    <pre class="moz-quote-pre" wrap="">

    </pre>
    <p>Bien sûr, <b>essayez cette commande sur des données <u>fictives</u></b>
    d'abord.</p>
    <p><br>
    </p>
    <p>Et je cherche des partenaires intéressés par RefPerSys en <a
    moz-do-not-send="true" href="http://refpersys.org/"
    class="moz-txt-link-freetext">http://refpersys.org/</a></p>
    <p>Librement<br>
    </p>
    <pre class="moz-signature" cols="72">--
    Basile Starynkevitch <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a>
    (only mine opinions / les opinions sont miennes uniquement)
    92340 Bourg-la-Reine, France
    web page: starynkevitch.net/Basile/

    </pre>
    </body>
    </html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?SsOpcsOpbXkgUHJlZ28=?=@21:1/5 to All on Fri Sep 9 20:10:01 2022
    Oupss, j'ai oublier le /d de la fin de la commande ... désolé

    sed '/49\.7\.20/d' /tmp/file.txt

    Jerem
    Le 09/09/2022 à 19:47, Jérémy Prego a écrit :
    Bonjour,

    et en échappant les "." ?

    genre:
    sed '/49\.7\.20/' /tmp/file.txt

    Jerem
    Le 09/09/2022 à 19:22, antoine.valmer a écrit :
    Bonjour à tous,
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022

    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."
    @+ et merci.
    A. Valmer



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?utf-8?Q?=C3=89tienne?= Mollier@21:1/5 to All on Fri Sep 9 21:10:01 2022
    Bonjour,

    antoine.valmer, on 2022-09-09:
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022

    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."

    Bizarre, chez moi ça marche :

    $ echo '49.7.20.111|17August2022' | sed '/49.7.20/d'
    $ echo '49.7.20.120|18August2022' | sed '/49.7.20/d'
    $ echo '11.2.33.123|19August2022' | sed '/49.7.20/d'
    11.2.33.123|19August2022

    Peut-être qu'il y a une subtilité entre différentes versions de
    sed utilisées ? Mais j'ai essayé avec GNU sed et busybox sed
    sans avoir de problèmes :

    $ sed --version
    sed (GNU sed) 4.8
    Packaged by Debian
    Copyright (C) 2020 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
    […]

    $ busybox sed --version
    This is not GNU sed version 4.0

    Bonne soirée,
    --
    Étienne Mollier <[email protected]>
    Fingerprint: 8f91 b227 c7d6 f2b1 948c 8236 793c f67e 8f0d 11da
    Sent from /dev/tty1, please excuse my verbosity.

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEj5GyJ8fW8rGUjII2eTz2fo8NEdoFAmMbjg4ACgkQeTz2fo8N Edp4mA//QgoTGU1LMu/YmJoAh3E3O/J+eDe29y23fHVhsLgqRbo5HbgjM9lbo/U9 NtC0sqEsgduVzdQ3nhZIWZd9EZaiPcaNSGxQB3kqutxFb5nuxQh44Qqc0qCpCwVl iY29zpkVRVVtlZaJsBXxCWJ1goXKfzuebG6PWt/UYPgtofiM7zJwhve+7Q6bPc4i Pa/W+CVlNx3o42Cy6O4UiF0i4trWSwlxxZlMXEykY0AACbV/jN1kFQCMZ3uWlGUr PT5L64FBd5F8Yi7FCSUr+2nCvVTXjz4XVuNEHRZJX33X50ZnVv7iezyJ8kjFqb3f twWntXXQ+6i09K4zeXjix0hFBuRdP1HyG1NHpxI8DrWccYIwcieCgTw3uW8XLRF6 /CWCry22n6+elHxj9Ps5jOjAl8KgcsBcutNqApNe7dzeYyLV6Kjv4tJWW5rgEvB6 exqgVKXSTkHCRzUQdohJglzMDXoo5Qy9rEIeVfgBHfmNigrceoh5h1lNMfAUktya hJMZH5AHMlk3RIDX2X7TODMTTbaTublmLl1+2z8TCRnucoSvTUqLprPhVeZvepB9 oJkGin54CApU031vV3nVG7kW4BDxB0KuPL5DN7Ys2Vej9pg+lAAUBV+NZtYFdWhR R03/IoCVnOXP+0ks0N4OPWT6ASt/VKZOryMkhy9nrJpZwtvD6Co=
    =+0YD
    -----END PGP SIGNATURE-----

    --- Soup
  • From Pierre ESTREM@21:1/5 to All on Fri Sep 9 21:50:01 2022
    Bonsoir,

    Attention à ne pas avoir inséré un caractère spécial à la place d'un espace.
    Ca m'est arrivé (comme à d'autres).

    pierre estrem


    Le 09/09/2022 à 19:22, antoine.valmer a écrit :
    Bonjour à tous,
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022

    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."
    @+ et merci.
    A. Valmer


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Chantreux@21:1/5 to All on Fri Sep 9 22:30:01 2022
    salut,

    sed '/49.7.20/d'

    je te confirme que le script est bon ... meme trop puisque 4937420 va
    aussi matcher.

    pour bien faire il te faudrait

    sed '/49[.]7[.]20/d'

    mais le plus rapide (� l'�criture et � l'excution) est de chercher une
    chaine litterale puisque c'est ton cas:

    grep -vF 49.7.20

    il faut �videment que tu donnes un nom de fichier ou que stdin puisse
    consommer qqchose.

    mais elle n'efface aucune ligne contenant "49.7.20."

    comme ton probl�me n'est pas dans ton sedscript, tu pourrais nous donner
    un exemple plus complet (entr�e, commande compl�te, sortie)?

    par exemple chez moi

    <<. cat > oops
    49.7.20.111|17August2022
    49.7.20.120|18August2022
    11.2.33.123|19August2022
    .

    for cmd desc (
    9/sed '9base sed'
    t/sed 'toybox sed'
    b/sed 'busybox sed'
    sed 'coreutils sed'
    ) {
    print avec $desc
    $cmd '/49.7.20/d' oops
    echo
    }

    me donne bien

    avec 9base sed
    11.2.33.123|19August2022

    avec toybox sed
    11.2.33.123|19August2022

    avec busybox sed
    11.2.33.123|19August2022

    avec coreutils sed
    11.2.33.123|19August2022

    --
    Marc Chantreux
    P�le de Calcul et Services Avanc�s � la Recherche (CESAR) http://annuaire.unistra.fr/p/20200

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Chantreux@21:1/5 to Pierre ESTREM on Fri Sep 9 22:30:01 2022
    On Fri, Sep 09, 2022 at 09:41:14PM +0200, Pierre ESTREM wrote:
    Attention à ne pas avoir inséré un caractère spécial à la place d'un espace.
    Ca m'est arrivé (comme à d'autres).

    la bonne astuce pour verifier: tapper fc

    la commande s'ouvre alors dans editor et si c'est vim. perso j'ai

    set listchars=tab: │,trail:▧,nbsp:▧

    et dans 99% je découvre que j'ai introduit un espace npsp pret d'un pipe (alt-space alt-6 au lieu de space alt-6).

    --
    Marc Chantreux
    Pôle de Calcul et Services Avancés à la Recherche (CESAR) http://annuaire.unistra.fr/p/20200

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Marc@21:1/5 to All on Sat Sep 10 12:30:01 2022
    --------------f9gajIv75xE4qdFOgF0nAW3W
    Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: base64

    TGUgOS8wOS8yMiDDoCAxOToyMiwgYW50b2luZS52YWxtZXIgYSDDqWNyaXTCoDoNCj4gQm9u am91ciDDoCB0b3VzLA0KPiBEYW5zIHVuIGZpY2hpZXIgdGV4dGUsIGonYWkgY2UgdHlwZSBk ZSBsaWduZXMgOg0KPiA0OS43LjIwLjExMXwxN0F1Z3VzdDIwMjINCj4gNDkuNy4yMC4xMjB8 MThBdWd1c3QyMDIyDQo+IA0KPiBKZSBzb3VoYWl0ZSBzdXBwcmltZXIgdG91dGVzIGNlbGxl cyBxdWkgb250IGNldHRlIGV4cHJlc3Npb24gOg0KPiAiNDkuNy4yMC4iDQo+IEonYWkgdGVu dMOpIGNldHRlIGNvbW1hbmRlIDoNCj4gc2VkICcvNDkuNy4yMC9kJw0KPiBtYWlzIGVsbGUg bidlZmZhY2UgYXVjdW5lIGxpZ25lIGNvbnRlbmFudCAiNDkuNy4yMC4iDQoNCnNlZCAtaSAn L140OVwuN1wuMjAvZCcgbm9tLWRlLXRvbi1maWNoaWVyDQoNCg0KDQo+IEArIGV0IG1lcmNp Lg0KDQpkZSByaWVuLg0KPiBBLiBWYWxtZXINCg0KLS0gDQpKZWFuLU1hcmMNCg==

    --------------f9gajIv75xE4qdFOgF0nAW3W--

    -----BEGIN PGP SIGNATURE-----

    iHUEARYIAB0WIQQe1tJ1wH7aHlIabXRcceD57QuFWAUCYxxThwAKCRBcceD57QuF WMCQAP9Oz5m5wzeK5nGfji1PJFwVf/m77y4J0nWsuCuLRNvVYgD9HDdmWUEIVBeJ sdst8gRnnCqOViwz+dJzri1zzJSjswQ=
    =qbWt
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From antoine.valmer@21:1/5 to All on Mon Sep 12 13:00:01 2022
    Le 9/09/22 à 19:22, antoine.valmer a écrit :
    Bonjour à tous,
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022
    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."

    Hello,
    Grand merci à tous ceux qui m'ont répondu,
    voici la commande que j'ai tapée :
    sed -i '/49.7.20/d' fichier.txt
    qui a bien marché.
    Je retiens aussi les autres commandes qui m'ont été indiquées.
    Bonne journée.

    On Saturday 10 September 2022 11:06:15 Jean-Marc et d'autres wrote:
    sed -i '/^49\.7\.20/d' nom-de-ton-fichier

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Pierre Malard@21:1/5 to All on Mon Sep 12 18:30:01 2022
    --Apple-Mail=_F0D367FC-F2F8-4D20-A40B-EF103619DCDD
    Content-Transfer-Encoding: quoted-printable
    Content-Type: text/plain;
    charset=utf-8

    Salut,

    Histoire d’en rajouter une couche, la suggestion d’échapper les points était LA bonne solution car le point est interprété comme un caractère … quelconque ce qui peut être assez gênant non ?

    J’aurais donc donné cette commande :
    $ sed -i '/^49\.7\.20\./d' fichier.txt
    sans le « -i » pour faire un test d’abord.

    PS :
    Il est préférable d’ajouter également le « . » à la fin pour éviter de supprimer par exemple une ligne « 49.7.201 » qu’on souhaiterai conserver par exemple…

    A+

    Le 12 sept. 2022 à 12:41, antoine.valmer <[email protected]> a écrit :

    Le 9/09/22 à 19:22, antoine.valmer a écrit :
    Bonjour à tous,
    Dans un fichier texte, j'ai ce type de lignes :
    49.7.20.111|17August2022
    49.7.20.120|18August2022
    Je souhaite supprimer toutes celles qui ont cette expression :
    "49.7.20."
    J'ai tenté cette commande :
    sed '/49.7.20/d'
    mais elle n'efface aucune ligne contenant "49.7.20."

    Hello,
    Grand merci à tous ceux qui m'ont répondu,
    voici la commande que j'ai tapée :
    sed -i '/49.7.20/d' fichier.txt
    qui a bien marché.
    Je retiens aussi les autres commandes qui m'ont été indiquées.
    Bonne journée.

    On Saturday 10 September 2022 11:06:15 Jean-Marc et d'autres wrote:
    sed -i '/^49\.7\.20/d' nom-de-ton-fichier


    --
    Pierre Malard
    Responsable architectures système CDS DINAMIS/THEIA Montpellier
    IRD - UMR Espace-Dev - UAR CPST - IR Data-Terra
    Maison de la Télédétection
    500 rue Jean-François Breton
    34093 Montpellier Cx 5
    France

    « Le socialisme vrai ne veut pas renverser l'ordre des classes ;
    il veut fondre les classes dans une organisation du travail qui
    sera meilleure pour tous »
    Jean Jaures - "Les misères du patronat" - 1890
    _,'| _.-''``-...___..--';)
    /_ \'. __..-' , ,--...--'''
    <\ .`--''' ` /'
    `-';' ; ; ;
    __...--'' ___...--_..' .;.'
    (,__....----''' (,..--'' πr

    perl -e '$_=q#: 3|\ 5_,3-3,2_: 3/,`.'"'"'`'"'"' 5-. ;-;;,_: |,A- ) )-,_. ,\ ( `'"'"'-'"'"': '"'"'-3'"'"'2(_/--'"'"' `-'"'"'\_): 24πr::#;y#:#\n#;s#(\D)(\d+)#$1x$2#ge;print'
    - --> Ce message n’engage que son auteur <--


    --Apple-Mail=_F0D367FC-F2F8-4D20-A40B-EF103619DCDD
    Content-Transfer-Encoding: quoted-printable
    Content-Type: text/html;
    charset=utf-8

    <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Salut,<div class=""><br class=""></div><div class="">Histoire d’
    en rajouter une couche, la suggestion d’échapper les points était LA bonne solution car le point est interprété comme un caractère … quelconque ce qui peut être assez gênant non ?</div><div class=""><br class=""></div><div class="">J’aurais
    donc donné cette commande :</div><div class=""><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>$ sed -i '/^49\.7\.20\./d' &nbsp;fichier.txt</font></div><div class="">sans le «&nbsp;-i&nbsp;» pour faire un
    test d’abord.</div><div class=""><br class=""></div><div class="">PS :</div><div class="">Il est préférable d’ajouter également le «&nbsp;.&nbsp;» à la fin pour éviter de supprimer par exemple une ligne «&nbsp;49.7.201&nbsp;» qu’on
    souhaiterai conserver par exemple…</div><div class=""><br class=""></div><div class="">A+</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">Le 12 sept. 2022 à 12:41, antoine.valmer &lt;<a href="
    mailto:[email protected]" class="">[email protected]</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" class="">Le 9/09/22 à 19:22, antoine.valmer a écrit&nbsp;:<br class=""><
    blockquote type="cite" class="">Bonjour à tous,<br class="">Dans un fichier texte, j'ai ce type de lignes :<br class="">49.7.20.111|17August2022<br class="">49.7.20.120|18August2022<br class="">Je souhaite supprimer toutes celles qui ont cette
    expression :<br class="">"49.7.20."<br class="">J'ai tenté cette commande :<br class="">sed '/49.7.20/d'<br class="">mais elle n'efface aucune ligne contenant "49.7.20."<br class=""></blockquote></blockquote><br class="">Hello,<br class="">Grand merci à
    tous ceux qui m'ont répondu,<br class="">voici la commande que j'ai tapée :<br class="">sed -i '/49.7.20/d' fichier.txt<br class="">qui a bien marché.<br class="">Je retiens aussi les autres commandes qui m'ont été indiquées.<br class="">Bonne
    journée.<br class=""><br class=""><blockquote type="cite" class="">On Saturday 10 September 2022 11:06:15 Jean-Marc et d'autres wrote:<br class="">sed -i '/^49\.7\.20/d' nom-de-ton-fichier<br class=""></blockquote><br class=""></div></div></blockquote></
    <br class=""><div class="">
    <div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-
    wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space:
    normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-
    spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"
    class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-
    break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-
    nbsp-mode: space; line-break: after-white-space;" class=""><div style="margin: 0px; font-size: 10px; font-family: &quot;Courier New&quot;;" class="">--&nbsp;</div><div style="margin: 0px; font-size: 10px; font-family: &quot;Courier New&quot;;" class=""><
    div style="margin: 0px;" class="">Pierre Malard</div><div style="margin: 0px;" class="">Responsable architectures système CDS DINAMIS/THEIA Montpellier</div><span style="font-size: x-small;" class="">IRD - UMR Espace-Dev - UAR CPST - IR Data-Terra</span>
    <br class=""><div style="margin: 0px;" class="">Maison de la Télédétection</div><div style="margin: 0px;" class="">500 rue Jean-François Breton</div><div style="margin: 0px;" class="">34093 Montpellier Cx 5</div><div style="margin: 0px;" class="">
    France</div><div class=""><br class=""></div></div><div style="margin: 0px; font-family: Times;" class="">&nbsp; &nbsp;«&nbsp;<i class="">Le socialisme vrai ne veut pas renverser l'ordre des classes ;</i></div><div style="margin: 0px; font-family: Times;
    " class=""><i class="">&nbsp; &nbsp;il veut fondre les classes dans une organisation du travail qui</i></div><div style="margin: 0px; font-family: Times;" class=""><i class="">&nbsp; &nbsp;sera meilleure pour tous&nbsp;</i>»</div><div style="margin: 0px;
    font-family: Times;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Jean Jaures&nbsp;- "Les misères du patronat" - 1890</div><div style="margin: 0px; font-size: 10px; font-family: &quot;
    Courier New&quot;;" class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;_,'| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _.-''``-...___..--';)</div><div style="margin: 0px; font-size: 10px; font-family: &quot;Courier New&quot;;" class="">&nbsp;&nbsp; &nbsp; &nbsp; /_
    \'. &nbsp; &nbsp; &nbsp;__..-' , &nbsp; &nbsp; &nbsp;,--...--'''</div><div style="margin: 0px; font-size: 10px; font-family: &quot;Courier New&quot;;" class="">&nbsp;&nbsp; &nbsp; &nbsp;&lt;\ &nbsp; &nbsp;.`--''' &nbsp; &nbsp; &nbsp; ` &nbsp; &nbsp; /'</
    <div style="margin: 0px; font-size: 10px; font-family: &quot;Courier New&quot;;" class="">&nbsp;&nbsp; &nbsp; &nbsp; `-';' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; &nbsp; ; ;</div><div style="margin: 0px; font-size: 10px; font-family: &quot;
    Courier New&quot;;" class="">&nbsp;__...--'' &nbsp; &nbsp; ___...--_..' &nbsp;.;.'</div><div style="margin: 0px; font-size: 10px; font-family: &quot;Courier New&quot;;" class="">(,__....----''' &nbsp; &nbsp; &nbsp; (,..--'' &nbsp; &nbsp; &nbsp; &nbsp;πr<
    /div><div style="margin: 0px; font-family: Times; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 10px; font-family: &quot;Courier New&quot;;" class="">perl -e '$_=q#: 3|\ 5_,3-3,2_: 3/,`.'"'"'`'"'"' 5-. &nbsp;;-;;,_: &
    nbsp;|,A- &nbsp;) )-,_. ,\ ( &nbsp;`'"'"'-'"'"': '"'"'-3'"'"'2(_/--'"'"' &nbsp;`-'"'"'\_): 24πr::#;y#:#\n#;s#(\D)(\d+)#$1x$2#ge;print'</div><div style="margin: 0px; font-family: &quot;Courier New&quot;;" class=""><span style="font-size: 10px;" class="">-
    --&gt; Ce message n’engage que son auteur &lt;--</span></div></div></div></div></div></div>
    </div>
    <br class=""></div></body></html> --Apple-Mail=_F0D367FC-F2F8-4D20-A40B-EF103619DCDD--

    -----BEGIN PGP SIGNATURE-----

    iQIzBAEBCgAdFiEE0KHTJ+AWKhmI+acm/pSWHuad/BgFAmMfWrsACgkQ/pSWHuad /BgqsBAAmdeCAQI8snYxGyraX/hZwYwgxfY5u6v6uD05qXUxHJMwk9ovn9O3W+gs qQnvg+433ZsP05/ecH2oNzcqahMu29QQTUhQ8gxkpvvA7IXL8anlLg3Ugss/6VbB Ef9CCJo1igiW38suSGOTbZsb6hfGTUYk5+Hwr50gtw6veGDpGS4GOirNu/tJY3jm FxaEy64Hg9mWIPP66IaTf/H/pocv4WQorwEl427GSALj3WuTpASDq3GXoi2Fy/pb FxSrXCPn4ub7JfypaHe+cf8TV5Opd9g8jfbkC5J2w0hWixxGVCED4xlhAaH4YERR qoAstl2rv6gReyosZRw1nvHmnyNniZ25J0QMGBPujZmWKfN4bqJlch6WAwwfDYxV BLcw3Qrj2ww0IBTo0oVxfRpbj7rtd/kOG8JsPsDbkfv9DarFXVw3Ko+1HgIF+VQc SkPavAKbuc6evZiAIVXETl6jGOzpze4rJzL69kZyIknIVzkNPvkxd6QZWZK3pfYc P8f8yUYiYk8HlEHIDDKp84peNxdRtUdu2yw8Ss0XMjc5o6WfhTrT0yHlB91WxnCG X8dAliwrJcXfYVBCuEcLM/grx7PFydL9B/LorHPkgWGW3zQP8wUCcPKrR3+e/GCQ iXD2wvbgHbxpw0to1ymEp6JA7VO75xkgHOnNMMFdu2yqDf9CN8I=
    =9YJW
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Chantreux@21:1/5 to All on Mon Sep 12 18:50:02 2022
    salut,

    J’aurais donc donné cette commande :
    sed -i '/^49\.7\.20\./d' fichier.txt

    perso je metacaractère entre crochets parceque je trouve ca plus facile
    * de le visualiser apres coup
    * de l'étendre (le [.] qui devient [ :] avec le temps)
    * de l'embarquer dans un autre script en réduisant le quoting hell

    sed -i '/^49[.]7[.]20[.]/d' fichier.txt

    Il est préférable d’ajouter également le « . » à la fin pour éviter de
    supprimer par exemple une ligne « 49.7.201 » qu’on souhaiterai
    conserver par exemple…

    et si jamais tu veux trouver '49.' autre part qu'au début de ta ligne,
    un début de mot (\<) t'évitera d'embraquer 149. attention, il te faut l'utiliser avec -r ou -E (je préfère noter -r par experience d'autres impleméntations de sed).

    <<. sed -r '/\<49[.]/d'
    149.
    # 49.
    .49.
    route49.
    # 149.
    49.

    donne:

    149.
    route49.
    # 149.

    --
    Marc Chantreux
    Pôle de Calcul et Services Avancés à la Recherche (CESAR) http://annuaire.unistra.fr/p/20200

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)