Outils pour utilisateurs

Outils du site


tech:notes_sed_grep_regex

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édentesRévision précédente
Prochaine révision
Révision précédente
tech:notes_sed_grep_regex [2025/04/01 16:09] Jean-Baptistetech:notes_sed_grep_regex [2025/12/15 16:21] (Version actuelle) Jean-Baptiste
Ligne 7: Ligne 7:
  
 Voir : Voir :
 +* `man regex`
 * [[grep avec option p comme AIX - Récupérer un paragraphe complet]] * [[grep avec option p comme AIX - Récupérer un paragraphe complet]]
  
 +Voir aussi : 
 +* pcregrep
  
 ## Regex ## Regex
Ligne 17: Ligne 19:
 ^((?!motif).)*$ ^((?!motif).)*$
 ~~~ ~~~
 +
 +
 +Grepper sur plusieurs lignes (match grep with line break)
 +~~~bash
 +grep -zP '\S{64}\n\S{64}'
 +~~~
 +
  
 ### Extended regular expressions ### Extended regular expressions
Ligne 37: Ligne 46:
     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. 
 ~~~ ~~~
 +
 +Trouver des tabulations dans un fichier (GNU grep) you can use the Perl-style regexp
 +~~~bash
 +grep -P '\t' *
 +~~~
 +
  
 ### Pb  ### Pb 
  
-#### Pb Binary file daemon.log matches+#### Pb binary file matches
  
  
Ligne 174: Ligne 189:
 Voir : Voir :
 * https://www.redhat.com/sysadmin/gawk-word-game * https://www.redhat.com/sysadmin/gawk-word-game
 +
 +Utiliser les variables d'environement dans awk :
 +~~~bash
 +awk -v a="$var1" -v b="$var2" 'BEGIN {print a,b}'
 +~~~
  
 Dernier champ ; avant dernier champ Dernier champ ; avant dernier champ
Ligne 250: Ligne 270:
  
 calc_sum() { awk '{s+=$1} END {printf "%.0f", s}' "$*" } calc_sum() { awk '{s+=$1} END {printf "%.0f", s}' "$*" }
 +~~~
 +
 +### Awk autres
 +
 +''/etc/auto.smb''
 +~~~bash
 +# .........
 +$SMBCLIENT -gNL $key 2>/dev/null| awk -v key="$key" -v opts="$opts" -F'|' -- '
 +        BEGIN   { ORS=""; first=1 }
 +        /Disk/  {
 +                  if (first)
 +                        print opts; first=0
 +                  dir = $2
 +                  loc = $2
 +                  # Enclose mount dir and location in quotes
 +                  # Double quote "$" in location as it is special
 +                  gsub(/\$$/, "\\$", loc);
 +                  print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
 +                }
 +        END     { if (!first) print "\n"; else exit 1 }
 +        '
 ~~~ ~~~
  
tech/notes_sed_grep_regex.1743516582.txt.gz · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki