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 thought on “Trac – Emptying a Wiki database”

  1. 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

Your email address will not be published. Required fields are marked *

Scroll to Top