Saturday, July 14, 2007

tcsh loop with variable names

tcsh script to rename files modifying the name

> foreach X ( *03.root )
foreach? set newname=`echo $X | sed s/iteration03/iteration04/`
foreach? mv $X $newname ;
foreach? end

Also, using variables with sed :
> foreach X (E002 E004 E005 E009 E020 E030 E050 E100)
or

> foreach X ( `ls /data1/gerbaudo/1_5_2/mc-pi-hepmc-ca* | cut -d "_" -f 4` )
foreach? sed "s/E000/$X/g" templateE000.cfg > $X.cfg ;
foreach? end

No comments: