Archive

Posts Tagged ‘delete’

How to Delete Existing WordPress Post Revisions

February 19th, 2010 admin Comments off

To remove all existing post revisions entries from WordPress database Posts table, simply login to MySQL phpMyAdmin. Select the appropriate WordPress database, and then issue the following command:

DELETE FROM wp_posts WHERE post_type = "revision";

it’s recommended to backup the database before performing the deletion SQL statements.

Categories: CMS Tags: , , , ,

Remove Text from Multiple Files

February 18th, 2010 admin Comments off

Shell script to remove some text from multiple files

Here is a small script that reads all *.txt  or all *.html, all *.php  files and delete all lines between word1 and word2:

#!/bin/bash
FILES="*.php"
for f in $FILES
do
INF="$f"
OUTF="$f.out.tmp"
# replace
sed '/word1/,/word2>/d' $INF > $OUTF
/bin/cp $OUTF $INF
/bin/rm -f $OUTF
done

Then save this file as “myscript.txt”

run this script with: # bash myscript.txt

Categories: Linux Tags: , , , , , , , ,