Remplacer un caractère à travers shell

Fermé
chiefNam Messages postés 5 Date d'inscription mardi 14 août 2018 Statut Membre Dernière intervention 17 août 2018 - 14 août 2018 à 12:26
zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 - 17 août 2018 à 13:54
bonjour Team,

j'essai de remplacer à partir d'un shell le caractère '\' suivi des retour à la ligne dans un fichier par le vide.

c'est a dire partir de ca



à
A voir également:

2 réponses

zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 6 407
14 août 2018 à 13:06
Salut,

Il aurait été plus judicieux de nous faire un copier/coller d'un bout de ton fichier plutôt que de mettre des captures d'écran ;-(

Un truc du genre devrait le faire (sous réserve qu'il n'y ait pas de caractères sournois dans ton fichier) :

$ cat f1 
qdqsdqsgd|klqsdq|qkhdqsklhdqskl \
|hsdjkfhsjfh|kfjdfjsdk|||
gjldmfjgldfm|glmdfgk|mjc \
|fjsdkl|klsdf|||


$ sed ':z;N;$!bz;s/\\\n/|/g' f1 
qdqsdqsgd|klqsdq|qkhdqsklhdqskl ||hsdjkfhsjfh|kfjdfjsdk|||
gjldmfjgldfm|glmdfgk|mjc ||fjsdkl|klsdf|||

1
chiefNam Messages postés 5 Date d'inscription mardi 14 août 2018 Statut Membre Dernière intervention 17 août 2018
16 août 2018 à 16:59
Salut @zipe31,

Ci-dessous le contenu

hhhth|yuiok,|fee|rtnjjk| |derf|xcvg| |ghjui|tgrfe|g|14/06/2018|huuj|uytr|5896,0|x|hikioujk \
|Z|gtyyhju| | | | | | |896|hjyj|yjyj|| |rtj|rzrtyh| |h|r|e| ||rey|hyh|grry|ryy|hji,0|htrh|th|0| | |thj| |thtj| ||| | | | |
jyjj|yj|rj|rtj| |rtj|rtj| |rtj|ffh|3|14/06/2018|9000|14/06/2018|33000,0|C|olppkh \
|Z|gtyyhju| | | | | | |896|hjyj|yjyj|| |rtj|rzrtyh| |h|r|e| ||rey|hyh|grry|ryy|hji,0|htrh|th|0| | |thj| |thtj| ||| | | | |
hhhth|yuiok,|fee|rtnjjk| |derf|xcvg| |ghjui|tgrfe|g|14/06/2018|huuj|uytr|5896,0|x|hikioujk \
|Z|gtyyhju| | | | | | |896|hjyj|yjyj|| |rtj|rzrtyh| |h|r|e| ||rey|hyh|grry|ryy|hji,0|htrh|th|0| | |thj| |thtj| ||| | | | |
jyjj|yj|rj|rtj| |rtj|rtj| |rtj|ffh|3|14/06/2018|9000|14/06/2018|33000,0|C|olppkh \
|Z|gtyyhju| | | | | | |896|hjyj|yjyj|| |rtj|rzrtyh| |h|r|e| ||rey|hyh|grry|ryy|hji,0|htrh|th|0| | |thj| |thtj| ||| | | | |
hhhth|yuiok,|fee|rtnjjk| |derf|xcvg| |ghjui|tgrfe|g|14/06/2018|huuj|uytr|5896,0|x|hikioujk \
|Z|gtyyhju| | | | | | |896|hjyj|yjyj|| |rtj|rzrtyh| |h|r|e| ||rey|hyh|grry|ryy|hji,0|htrh|th|0| | |thj| |thtj| ||| | | | |
jyjj|yj|rj|rtj| |rtj|rtj| |rtj|ffh|3|14/06/2018|9000|14/06/2018|33000,0|C|olppkh \
|Z|gtyyhju| | | | | | |896|hjyj|yjyj|| |rtj|rzrtyh| |h|r|e| ||rey|hyh|grry|ryy|hji,0|htrh|th|0| | |thj| |thtj| ||| | | | |

je souhaite avoir au rendu ceci:
0
zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 6 407 > chiefNam Messages postés 5 Date d'inscription mardi 14 août 2018 Statut Membre Dernière intervention 17 août 2018
16 août 2018 à 18:11
Salut,

Ben la commande donnée ci-dessus (
sed ':z;N;$!bz;s/\\\n/|/g'
) fait exactement ce que tu veux ;-))
0
chiefNam Messages postés 5 Date d'inscription mardi 14 août 2018 Statut Membre Dernière intervention 17 août 2018
17 août 2018 à 10:14
Salut,
j'ai essayé mais j'ai un Feedback, ci dessous la capture.
0
zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 6 407 > chiefNam Messages postés 5 Date d'inscription mardi 14 août 2018 Statut Membre Dernière intervention 17 août 2018
17 août 2018 à 10:22
Sur quel système es-tu ? Quelle version de sed ?

Essaie comme ça :
sed -e ':z' -e 'N' -e '$!bz' -e 's/\\\n/|/g'
0
chiefNam Messages postés 5 Date d'inscription mardi 14 août 2018 Statut Membre Dernière intervention 17 août 2018
17 août 2018 à 13:25
la version du sed est sed 4.2.2.
le systeme est win 10.
je travaille à distance sur le serveur à travers le protocole de communication genero
0
cs_PaTaTe Messages postés 2126 Date d'inscription mercredi 21 août 2002 Statut Contributeur Dernière intervention 19 février 2021 493
14 août 2018 à 12:42
Bonjour,

Je suis assez mauvais avec awk mais un truc du genre :

awk 'BEGIN {ORS=" "} {print} END {print "\n"}' SOURCE

SOURCE étant la chaîne à modifier
0
chiefNam Messages postés 5 Date d'inscription mardi 14 août 2018 Statut Membre Dernière intervention 17 août 2018
14 août 2018 à 13:04
Merci bcp,
j'essai avec
0