LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-10-2016, 08:43 AM   #1
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Rep: Reputation: 13
Search for a word in multiple ODT files


Hi,

I'm trying to find specific words within multiple documents. All the answers so far result in nothing. Does anyone know a way I can search the contents of a folder containing multiple odt files for a specific word please?

I'm using LMDE and Libre office 1:4.3.3-2+deb8u3

Thanks
 
Old 05-10-2016, 08:53 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by NotAComputerGuy View Post
Does anyone know a way I can search the contents of a folder containing multiple odt files for a specific word please
Yes:
http://ubuntuforums.org/showthread.p...06#post5859706
http://www.linuxquestions.org/questi...es-4175511386/
http://superuser.com/questions/68220...ep-not-working

DuckDuckGo is your friend...

Best regards,
HMW
 
Old 05-10-2016, 09:37 AM   #3
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
The first link I've tried and none of the results listed return anything. I search for the word "the" which occurs multiple times in multiple documents and it displays nothing.

The second link states "ODT files are ZIP files containing a structure of files and directories. You can unzip them. The text is in xml format in content.xml." but I've got no idea how I would unzip multiple files and then search them all for a word. It seems unlikely that it's possible in my extremely limited knowledge. A single file I could achieve but multiple files seems unlikely.

The third results in:
caution: filename not matched: /home/user/path/to/documents/doc1.odt
caution: filename not matched: /home/user/path/to/documents/doc2.odt
caution: filename not matched: /home/user/path/to/documents/doc3.odt
/usr/bin/zipgrep: 97: test: -eq: unexpected operator
/usr/bin/zipgrep: 100: test: Illegal number:


Thanks for trying though. You say you know how it can be done, could you tell me directly please?
 
Old 05-10-2016, 09:54 AM   #4
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
People who come across this thread in future.

I found

Code:
for file in *.odt; do     unzip -c "$file" | grep -iq insertsearchtexthere && echo "$file"; done
to be the answer assuming all the files are in one directory.


That was found here: https://superuser.com/questions/6822...ep-not-working
 
4 members found this post helpful.
Old 05-10-2016, 11:28 AM   #5
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,325

Rep: Reputation: 760Reputation: 760Reputation: 760Reputation: 760Reputation: 760Reputation: 760Reputation: 760
Code:
zgrep -i -l insertsearchtexthere *.odt
No?
[edit]
Ah ok, zgrep is for gziped files...

Last edited by keefaz; 05-10-2016 at 11:31 AM.
 
Old 05-10-2016, 01:08 PM   #6
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by NotAComputerGuy View Post
Thanks for trying though. You say you know how it can be done, could you tell me directly please?
You solved it yourself Awesome!

Best regards,
HMW
 
Old 05-10-2016, 01:26 PM   #7
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by NotAComputerGuy View Post
The first link I've tried and none of the results listed return anything. I search for the word "the" which occurs multiple times in multiple documents and it displays nothing
But... this is strange.

I tried this solution myself and it works as one could expect. I have an .odt file with this content:
”Document containing keyword foo

End!“

This is located here on my machine
Code:
/home/HMW/Dokument/test.odt
Now, if I run the following (searchodt.sh):
Code:
find $HOME/Dokument -name "*.odt" | while read file
do
        unzip -ca "$file" content.xml | grep -qli "foo"
        if [ $? -eq 0 ]; then
                echo "Found keyword in: " $file
        fi  
done
I get this result:
Code:
./searchodt.sh 
Found keyword in:  /home/HMW/Dokument/test.odt
Not that it matters since you have already solved this, but it is odd it didn't work on your end.

Best regards,
HMW
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
why can't ODT format convert to Word XML correctly? newbiesforever Linux - Software 3 10-04-2013 01:45 AM
[SOLVED] Search files with a special word speigel205 Linux - Newbie 2 02-23-2012 07:11 PM
Word search in files using Bash nnjond Linux - Newbie 1 10-09-2010 06:01 PM
[SOLVED] how to search word in group of files using command sumeet inani Linux - Newbie 20 11-09-2009 08:46 AM
I have a harddrive that I want to search for deleted word files, what do I do first? abefroman Linux - Security 2 07-31-2005 08:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration