Monday, July 01, 2013
[linux] llamando sed desde un script de bash
truco: usar comillas dobles, no la simple! si no no funciona.
let counter=1;
let thenewid=1;
for line in $(cat ./old_ids.txt); do
(( thenewid = $(head -$counter ./new_ids.txt | tail -1) ))
let counter+=1;
echo "$counter: -> $line will be $thenewid";
for lefichier in $(cat ./filetochange.txt); do
echo "sed 's/$line/$thenewid/g' ./$lefichier > ./foo.txt";
sed "s/$line /$thenewid /g" ./$lefichier > ./foo.txt;
# diff $lefichier ./foo.txt
# echo "cp ./foo.txt $lefichier"
cp ./foo.txt $lefichier;
done;
done;