[Shell] cut dans un sed
Fermé
koma_666
Messages postés
429
Date d'inscription
mardi 26 juin 2007
Statut
Membre
Dernière intervention
9 mai 2016
-
Modifié par koma_666 le 24/10/2011 à 17:06
zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 - 24 oct. 2011 à 18:39
zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 - 24 oct. 2011 à 18:39
A voir également:
- [Shell] cut dans un sed
- Cap cut avis - Télécharger - Montage & Édition
- Mp3 cut - Télécharger - Édition & Montage
- Classic shell windows 11 - Télécharger - Personnalisation
- Cut pdf - Télécharger - PDF
- Image cut - Télécharger - Montage photo
1 réponse
zipe31
Messages postés
36402
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 419
24 oct. 2011 à 18:39
24 oct. 2011 à 18:39
Salut,
;-))
$ ls -1 fichier1.txt fichier2.txt fichier3.txt fichier4.txt foo.sh* objets.txt $ cat foo.sh #! /bin/bash #set -xv compte=1 while read line do sed -i.bak "s/XXXXXXXXXX/${line}/" fichier${compte}.txt ((compte++)) done < <(sed 's/\([^,]*,[^,]*,[^,]*\),/\1\n/g' objets.txt) $ cat objets.txt chaine1,chaine2,chaine3,chaine4,chaine5,chaine6,chaine7,chaine8,chaine9,chaine10,chaine11,chaine12 $ cat fichier1.txt select distinct c.classnamea2a2, c.namecontainerinfo from epmdocumentmaster m, ((select classnamea2a2, ida2a2, namecontainerinfo from project2) union all (select classnamea2a2, ida2a2, namecontainerinfo from wtlibrary) union all (select classnamea2a2, ida2a2, namecontainerinfo from pdmlinkproduct)) c where m.name in (XXXXXXXXXX) and m.CLASSNAMEKEYCONTAINERREFEREN=c.CLASSNAMEA2A2 and m.IDA3CONTAINERREFERENCE=c.IDA2A2; $ cat fichier2.txt select distinct c.classnamea2a2, c.namecontainerinfo from epmdocumentmaster m, ((select classnamea2a2, ida2a2, namecontainerinfo from project2) union all (select classnamea2a2, ida2a2, namecontainerinfo from wtlibrary) union all (select classnamea2a2, ida2a2, namecontainerinfo from pdmlinkproduct)) c where m.name in (XXXXXXXXXX) and m.CLASSNAMEKEYCONTAINERREFEREN=c.CLASSNAMEA2A2 and m.IDA3CONTAINERREFERENCE=c.IDA2A2; $ cat fichier3.txt select distinct c.classnamea2a2, c.namecontainerinfo from epmdocumentmaster m, ((select classnamea2a2, ida2a2, namecontainerinfo from project2) union all (select classnamea2a2, ida2a2, namecontainerinfo from wtlibrary) union all (select classnamea2a2, ida2a2, namecontainerinfo from pdmlinkproduct)) c where m.name in (XXXXXXXXXX) and m.CLASSNAMEKEYCONTAINERREFEREN=c.CLASSNAMEA2A2 and m.IDA3CONTAINERREFERENCE=c.IDA2A2; $ cat fichier4.txt select distinct c.classnamea2a2, c.namecontainerinfo from epmdocumentmaster m, ((select classnamea2a2, ida2a2, namecontainerinfo from project2) union all (select classnamea2a2, ida2a2, namecontainerinfo from wtlibrary) union all (select classnamea2a2, ida2a2, namecontainerinfo from pdmlinkproduct)) c where m.name in (XXXXXXXXXX) and m.CLASSNAMEKEYCONTAINERREFEREN=c.CLASSNAMEA2A2 and m.IDA3CONTAINERREFERENCE=c.IDA2A2; $ ./foo.sh $ ls -1 fichier1.txt fichier1.txt.bak fichier2.txt fichier2.txt.bak fichier3.txt fichier3.txt.bak fichier4.txt fichier4.txt.bak foo.sh* objets.txt $ cat fichier1.txt select distinct c.classnamea2a2, c.namecontainerinfo from epmdocumentmaster m, ((select classnamea2a2, ida2a2, namecontainerinfo from project2) union all (select classnamea2a2, ida2a2, namecontainerinfo from wtlibrary) union all (select classnamea2a2, ida2a2, namecontainerinfo from pdmlinkproduct)) c where m.name in (chaine1,chaine2,chaine3) and m.CLASSNAMEKEYCONTAINERREFEREN=c.CLASSNAMEA2A2 and m.IDA3CONTAINERREFERENCE=c.IDA2A2; $ cat fichier2.txt select distinct c.classnamea2a2, c.namecontainerinfo from epmdocumentmaster m, ((select classnamea2a2, ida2a2, namecontainerinfo from project2) union all (select classnamea2a2, ida2a2, namecontainerinfo from wtlibrary) union all (select classnamea2a2, ida2a2, namecontainerinfo from pdmlinkproduct)) c where m.name in (chaine4,chaine5,chaine6) and m.CLASSNAMEKEYCONTAINERREFEREN=c.CLASSNAMEA2A2 and m.IDA3CONTAINERREFERENCE=c.IDA2A2; $ cat fichier3.txt select distinct c.classnamea2a2, c.namecontainerinfo from epmdocumentmaster m, ((select classnamea2a2, ida2a2, namecontainerinfo from project2) union all (select classnamea2a2, ida2a2, namecontainerinfo from wtlibrary) union all (select classnamea2a2, ida2a2, namecontainerinfo from pdmlinkproduct)) c where m.name in (chaine7,chaine8,chaine9) and m.CLASSNAMEKEYCONTAINERREFEREN=c.CLASSNAMEA2A2 and m.IDA3CONTAINERREFERENCE=c.IDA2A2; $ cat fichier4.txt select distinct c.classnamea2a2, c.namecontainerinfo from epmdocumentmaster m, ((select classnamea2a2, ida2a2, namecontainerinfo from project2) union all (select classnamea2a2, ida2a2, namecontainerinfo from wtlibrary) union all (select classnamea2a2, ida2a2, namecontainerinfo from pdmlinkproduct)) c where m.name in (chaine10,chaine11,chaine12) and m.CLASSNAMEKEYCONTAINERREFEREN=c.CLASSNAMEA2A2 and m.IDA3CONTAINERREFERENCE=c.IDA2A2; $
;-))