Batch edition of all Writer files in the current directory (body text)

bsro3 () { P=`pwd`; S=$1; R=$2; ls *.odt > /dev/null 2>&1; if [[ $? -ne 0 ]]; then exit 1; fi; for i in *.odt; do mkdir ${P}/T; cd ${P}/T; unzip -qq "$P"/"$i"; sed -i "s/$S/$R/" ${P}/T/content.xml; zip -qq -r "$P"/"$i" *; cd ${P}; rm -rf ${P}/T; done; }
This function does a batch edition of all OOO3 Writer files in current directory. It uses sed to search a FOO pattern into body text of each file, then replace it to foo pattern (only the first match) . I did it because I've some hundreds of OOO3 Writer files where I did need to edit one word in each ones and open up each file in OOO3 gui wasn't an option. Usage: bsro3 FOO foo

What Others Think

You can replace all occurences using sed "s/FOO/foo/g", by the way.
halka · 619 weeks and 5 days ago
Hi Halka! Yes, you're right and I know about that, but as I just did need replace "a word" (only one occurrence), so the use of sed only for the first match. Anyway, thank you for your comment.
danpos · 619 weeks and 5 days ago
Yes, it’s interesting, I once studied it myself, devoted a lot of time to it, now I’ve switched to another activity. He began to write essays, dissertations. I recommend reading here my best materials about Racial Profiling. The problem is urgent, it is interesting to study in detail the question, all success in school and work!
ChristianAngles · 96 weeks and 6 days ago
Indeed, it's fascinating, I once concentrated on it myself, committed a great deal of time to it, presently I've changed to one more movement he started to compose articles,more info">anyspunthread about Racial Profiling the issue is earnest, it is fascinating to review with regards to detail the inquiry, all progress in school and work!
ClaudeVest · 2 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: