View Single Post
  #5 (permalink)  
Old 18-Aug-2007, 19:14
AndrewTheArt
Guest
 
Posts: n/a
Default

I was looking into this and actually wrote a batch script to unzip the ODT and search the correct file.. however, there is one problem. The file that contains the actual text is only one long line, not separate lines. When grep finds an occurrence of your word, it would just return the entire line every single time. It sucks...

Here's how far I got.

Code:
#!/bin/bash
mv $1.odt $1.zip
unzip $1.zip -d $1
cd $1
echo "Type in a search term."
read search
cat content.xml | grep "$search"
cd ..
rm -r $1
mv $1.zip $1.odt
Grep is just doing it's job, in reality. I'm sure there are some command line switches to modify grep for this purpose, but I'm not exactly excited about learning about them.

Maybe somebody with more grep experience than me would know how to modify the default delimiter (from a carriage return to something else?)

This

Code:
<text:p text:style-name="Standard">This is a simple test.</text:p><text:p text:style-name="Standard">I hope it works.</text:p><text:p text:style-name="Standard">Woohoo!</text:p></office:text></office:body></office:document-content>
Is equivalent to this

Code:
This is a simple test.
I hope it works.
Woohoo!
The delimiter needs to be </text> for most documents, because it essentially represents a carriage return for our purposes (but Grep doesn't know this)