5

I am trying to locate a LibreOffice/OpenOffice file which contains some text, but I don't know the file name.

Is there any possible way to locate said file using the Ubuntu's search file tool? If so, how? It seems that the search tool under Places only looks into plain text files. How should I proceed without using the command prompt?

1

2 Answers 2

5

GUI

Install searchmonkey, it's available from the repositories. It's easy enough, but if you still need some help with it, ask me and I'll see if I can figure it out for you.

Command Line

grep -R -i -a -n needle stack

grep is the tool needed to find text.
-R tells grep to search recursively.
-i tells grep to not be case-sensitive.
-a tells grep to treat binary files as plain text files.
-n tells grep to show you the line number where the needle is in the file.
needle is the piece of text you are looking for.
stack is where it should search. Because of the -R parameter you can use a directory here.

Example

grep -R -i -a -n "<html>" Websites

This will search for the text in every file in the folder Websites

I hope my explanation was enough for you to understand the use of all parameters. If not, feel free to ask more in a comment.

7
  • so there is no GUI tool in Ubuntu for finding files containing text?
    – Azim
    Jun 30, 2011 at 21:09
  • Ow xD How should I proceed without using the command prompt?, thought it said How should I proceed using the command prompt?. My mistake, I'll look for a GUI tool.
    – RobinJ
    Jun 30, 2011 at 21:11
  • Got one, just tested searchmonkey. Seems to be a great application wich I'll probably be using a lot myself from now on :p
    – RobinJ
    Jun 30, 2011 at 21:14
  • thanks for the tip about searchmonkey. However, it doesn't find seem to find any files with my needle. Whereas, the grep command does seem to work. Just trying to find a tool for a friend who is not comfortable with command line operations.
    – Azim
    Jun 30, 2011 at 21:32
  • My guess is that searchmonkey isn't able to find it, because it's a binary file... Maybe you've got more succes with this one? sourceforge.net/projects/grepgui
    – RobinJ
    Jul 1, 2011 at 9:51
0

Since LibreOffice/OpenOffice are basically XMLs inside a ZIP, for e.g. for ODTs:

find . -name "*.odt" -exec bash -c "echo \"{}\" && zipgrep -io mypattern \"{}\"" \;

This will work for any OpenDocument (ODF) or Microsoft's OOXML files.

I don't know how grep as-is could be of any help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .