Outils pour utilisateurs

Outils du site


linux:sed (lu 60524 fois)

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
Prochaine révision Les deux révisions suivantes
linux:sed [01-11-2013 21:41]
edmc73
linux:sed [16-02-2014 22:22]
edmc73 [Exemple en vrac]
Ligne 99: Ligne 99:
 Ici on a rajouté **1d** qui permet de supprimer la 1ère ligne. Ici on a rajouté **1d** qui permet de supprimer la 1ère ligne.
  
-==== Regexp extended ====+===== Exemple en vrac ===== 
 + 
 +Source 
 +<code>dublablacodecode<a href="/chemin/bien/precis/fichier.xyz">OnSenFoutDuNom</a>dublablacode 
 +dublablacodecode<a href="/chemin/bien/precis/fichier2.xyz">OnSenFoutDuNom</a>dublablacode</code> 
 + 
 +Résultat 
 +<code>fichier.xyz 
 +fichier2.xyz</code> 
 + 
 +Sed 
 +<code>sed -r 's/.*href=".*[$/](.*)".*/\1/' fichierSource</code> 
 + 
 +Extraire la date et la reformaté dans un nom de fichier 
 +   
 +  $ echo Pict_20140215_0945.jpg | sed -r 's/.*([0-9]{4})([0-9]{2})([0-9]{2})_([0-9]{2})([0-9]{2}).*/\3-\2-\1 \4:\5/' 
 +  15-02-2014 09:45 
 + 
 +===== Regexp extended =====
  
 On peut mettre l'option -r à la place de l'option -e et voici la différence On peut mettre l'option -r à la place de l'option -e et voici la différence
Ligne 105: Ligne 123:
 >Appendix A Extended regular expressions >Appendix A Extended regular expressions
 > >
->The only difference between basic and extended regular expressions is in the behavior of a few characters: ‘?’, ‘+’, parentheses, and >braces (‘{}’). While basic regular expressions require these to be escaped if you want them to behave as special characters, when using >extended regular expressions you must escape them if you want them to match a literal character.+>The only difference between basic and extended regular expressions is in the behavior of a few characters: ‘?’, ‘+’, parentheses, and  braces (‘{}’). While basic regular expressions require these to be escaped if you want them to behave as special characters, when using extended regular expressions you must escape them if you want them to match a literal character.
 > >
 >Examples: >Examples:
Ligne 118: Ligne 136:
 >becomes ‘(abc){2,3}’ when using extended regular expressions. It matches either ‘abcabc’ or ‘abcabcabc’.  >becomes ‘(abc){2,3}’ when using extended regular expressions. It matches either ‘abcabc’ or ‘abcabcabc’. 
 >\(abc*\)\1 >\(abc*\)\1
->becomes ‘(abc*)\1’ when using extended regular expressions. Backreferences must still be escaped when using extended regular >expressions. +>becomes ‘(abc*)\1’ when using extended regular expressions. Backreferences must still be escaped when using extended regular expressions.
  
  
linux/sed.txt · Dernière modification: 04-10-2020 12:00 de edmc73