libreoffice - writer - search options

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
8,355
Reaction score
7,255
Credits
33,173
Can't give you help on

is there a way to tell whats the newest version of libreoffice one may use with their distribution of linux

without at least knowing

the version of linux i'm using,

:)

and on
it should depend on the version of libreoffice (please correct me if i'm wrong)

we will. And you're wrong.

I have been using LO for over 8 years and 3 months, and it has always had the feature and it has always worked.

You could try purging LO, reboot and reinstall LO and see if there is a difference.

Cheers

Wizard
 


osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
541
Reaction score
450
Credits
4,997
marbles asked:
is there a way to tell whats the newest version of libreoffice one may use with their distribution of linux
In debian you can go to: https://tracker.debian.org/ and enter "libreoffice" and it'll take you to a page with all the versions that debian uses, including the most recent.

Just back on the word count issue, it's so long since I actually interacted with a docx file, that it hadn't occurred to me earlier how I treated them in the past. I used a program call docx2txt to convert the docx document to text, and then I could use ordinary linux tools to discover word counts, or anything else of interest since there are so many text analysing tools available in linux. It wasn't in any repositories at that time, however, I checked now and it's in the debian repos. Of course it never preserved any formatting of the original, but was a reliable reproduction of the text.
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,674
Reaction score
2,427
Credits
13,194
One way to do it, without having to install specialist tools is to unzip the file to stdout in the terminal, pipe it to grep and then count the number of occurrences with wc:
Bash:
unzip -ca /path/to/file.odt 2> /dev/null | \grep --binary-file=text -oi "searchTerm"  | wc -l

Where /path/to/file.odt is the path to the .odt file you want to search inside. Replace that with the path to the file you want to search in. And where "searchTerm" is the text to search for. This can be a single word, a literal string, or a regex (regular expression).

Breaking the command down:
In the unzip command, we use the -c and -a options.
-c unzips the file to stdout.
-a converts it to a text file (albeit binary text)
/path/to/file.odt is the path to the .odt file.
And 2> /dev/null hides any error messages by redirecting them to /dev/null, AKA the bit-bucket.

The unzipped and converted file is output to stdout and then piped to \grep. NOTE: The backslash \ in the invocation of grep is deliberate. This will escape any aliases that might be set up for grep, ensuring that the only parameters that grep receives are the ones we explicitly specify.
--binary-file=text tells grep that any binary data should be treated as text.
The -o option tells grep to only display the matching part of the line, instead of the entire line. This is because the binary data for the text in the file will be in a single, long, continuous line. Allowing us to see each individual result.
The -i just specifies to use a case-insensitive search. This is an optional thing. You can add any other grep options that you might need.
Then we have "searchTerm" - which is the text to search for. Obviously replace that with the actual word, text, or regular expression you want to search for in the file.
That should list all occurrences of the word, or pattern in the unzipped file.

Finally, we pipe the output from grep to wc -l to tell us how many lines of output grep returned, which tells us the number of occurrences of your word/text/pattern in the file.

But that will only work on .odt documents and other .od? files produced by Libreoffice, it won't work on .docx.
 
Last edited:

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,549
Reaction score
7,304
Credits
69,523
without having to install specialist tools is to unzip the file

See? I never thought about unzipping it first. I didn't even know that'd work.
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Latest posts

Top