On 8 May 2003, Patrick wrote: > Hello, > > Can anyone with some decent sed/awk/bash skills please tell me how I do > some magic in a specfile: > > 1) replace "%define cvsdate <date in past>" with "%define cvsdate > <today's date>" > > 2) add the following lines after a line "%changelog" > "* Thu May 8 2003 me <me@xxxxxx> > - autorebuild" Ok, here goes: [meetsma@xxxxxx test]$ cat specfile %define cvsdate <date in past> %changelog * Thu May 7 2003 - manual rebuild [meetsma@xxxxxx test]$ gawk -v date="`date +'%a %b %e %Y'`" '{ if ($1=="%changelog") {print $1"\n* " date " me <me@xxxxxx>\n- autorebuild"; next} print }' specfile |sed "s/^%define cvsdate .*$/%define cvsdate `date -I`/" >specfile.new [meetsma@xxxxxx test]$ cat specfile.new %define cvsdate 2003-05-08 %changelog * Thu May 8 2003 me <me@xxxxxx> - autorebuild * Thu May 7 2003 - manual rebuild [meetsma@xxxxxx test]$ diff specfile specfile.new 2c2 < %define cvsdate <date in past> --- > %define cvsdate 2003-05-08 7a8,9 > * Thu May 8 2003 me <me@xxxxxx> > - autorebuild -- Arend