Sed - Insérer des espacements
baissaoui
Messages postés
508
Date d'inscription
Statut
Webmaster
Dernière intervention
-
Document initial créé par Jipicy
* Ajouter une ligne blanche après chaque phrase (ponctuée par un retour chariot) :
*
Espacement dans un fichier

*
sed G fichier.txt
- Ajouter une ligne blanche après chaque phrase (ponctuée par un retour chariot), sans tenir compte des lignes blanches existantes :
sed '/^$/d;G' fichier.txt
- Ajouter deux lignes blanches après chaque phrase (ponctuée par un retour chariot) :
sed 'G;G' fichier.txt
- Insérer une ligne blanche avant chaque ligne "matchée" par "/motif/" ("motif" peut être une expression régulière) :
sed '/Fin/{x;p;x}' fichier.txt
- Insérer une ligne blanche après chaque ligne "matchée" par "/motif/" ("motif" peut être une expression régulière) :
sed '/Début/G' fichier.txt
- Insérer une ligne blanche avant et après chaque ligne "matchée" par "/motif/" ("motif" peut être une expression régulière) :
sed '/Stream EDitor/{x;p;x;G}' fichier.txt