Trac – Emptying a Wiki database

A quick bit of shell magic to empty a Trac wiki database in a freshly installed Trac environment. In this example /var/www/html/trac is assumed to be the Trac environment you created with trac-admin.

$ for page in `trac-admin /var/www/html/trac wiki list | cut -d' ' -f1 | grep "^[A-Z]" | grep -v "Title"`; do trac-admin /var/www/html/trac wiki remove $page; done;

;)

1 Comment so far
Leave a comment

Thanks for the tip. It proved to be very useful.

I would just add that I changed the grep expression to keep my existing pages. Running your command once with
grep “^Wiki” and once with grep “^Trac” was enough to remove the default wiki.



Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required, but not displayed publically)