This is an old revision of the document!


Search inside ODT files

This simple script will search all the ODT files in the current directory for the specified text string, printing out the names of all the files containing said string.

searchodt

#!/bin/bash
 
if [ $# -ne 1 ]; then
	echo "Usage: `basename $0` searchterm"
	exit 1
fi
 
for file in $(ls *.odt); do
	unzip -ca "$file" content.xml | grep -ql "$1"
	if [ $? -eq 0 ]; then
		echo "$file"
	fi
done