Pages

mardi 22 novembre 2011

replace some words in a text file with tcsh

#!/bin/tcsh

set mot_tochange = "0 lageos1_"
set new_mot = "-1 lageos1_"

set commonpath = "/home/xwang/gin/directeur/"
set testpath = "22066_22430_test/la1"

foreach f (`ls $commonpath$testpath*`)
echo "f= $f"
set filename = `basename $f`
set new_f = "/home/xwang/gin/directeur/22066_22430_eq_v9.2/$filename"


cat $f | head -n 28 > $new_f
grep "$mot_tochange" $f | sed "s;$mot_tochange;$new_mot;g" >> $new_f
cat $f | tail -n 36 >> $new_f
end

Aucun commentaire:

Enregistrer un commentaire