### PERL ############ ### Remplacer du texte $destination = $source; $destination =~ s/ceci/cela/g; ### Nombre d'occurences $nombre = ($F[0] =~ s/,/,/g); ### Extraire qq chose (un nombre) d'une expression rationnelle if ($_=~ /.*output.*:.*([0-9]{1,})/; $nboutput = $1;} ### Imprimer sur la sortie standard (STDIN) print STDOUT "bonjour" ### Selectionner une sortie select LOG print "bonjour"; ### Parcourir un tableau foreach $i (@a){} for ($i=0;$i<@a;$i++){ ### Parcourir un hachage foreach $i (keys %a){} while (($key,$value) = each(%a){} ### Ecrire dans un fichier particulier open(ABSTRACT,">$abstract"); print ABSTRACT "blabla"; ###Nombre d'entrées dans un hachage $num_Cara = scalar keys %RefOrth2; ###Comment parcourir 2x le même fichier open(UN,"<$ARGV[0]"); while(){ } close(UN); open(DEUX,"<$ARGV[0]"); while(){ } close(DEUX); ### Changer l'extension du fichier $nomfi=$ARGV[0]; $nomfi=~s/\..*$//; $nomdef=$nomfi.".def"; ###Expression régulières minimales: * -> *? + -> +? ### Envoyer une commande `sed -i "/FIN BLOC (PRESENTATION)/,/<\\/body>/d" $i`; !!!Attention aux / qu'il faut double slasher ### Faire du globbing @fichiers = glob("*.htm"); ### SED ############ ###Remplacer avec Sed s/pattern/remplace/g sed 's/a/b/g' temp4.txt >temp.txt ###Substitute "foo" with "bar" ONLY for lines which contain "baz" sed '/baz/s/foo/bar/g' file ### Supprimer entre deux indicateurs /1Mod/,/2Fin/d temp4.txt >temp.txt ### GAWK ############ ### Remplacements en ligne de commande gawk '{gsub(/\t$/,"");print $0}' temp4.txt >temp.txt # Retour chariot DOS: \r\n ### LS ############ ### Une seule colonne ### ls -1 *.html | gawk '{gsub(/.\[00m/,"");print $0}' >temp.txt  dépend du type de fichier