Unzip and zip OpenOffice.org ODT files

As you probably know, ODT files of OpenOffice.org (LibreOffice) are in essence just ZIP archives.

It is very easy to unpack them. But it is not so easy to create them. If you simply zip the contents of unpacked ODT and change the extension to .odt, it will not work.

The key here is that the mimetype file shall come into the archive first.

Two simple bash scripts are given here to extract and then pack back the ODT files.


Script odt_extract (provide  .odt file name and desired destination directory as command line arguments):

echo "Extracting ODT file $1 to directory $2 ..."
unzip "$1" -d "$2"   #1>/dev/null


Script odt_compress (provide  source directory and desired .odt file name as command line arguments):

echo "Compressing contents of directory $1 into ODT compatible document $2 ... "
# Move into document source directory
cd "$1"
# Special zipping procedure to create correctly structured ODT file
# Remember that if the provided resulting file path is relative, it shall be so in respect to the current working directory!
# First comes the "mimetype" file ...
zip -0 -X "$2" mimetype   #1>/dev/null
# ... then everything else follows
zip -r "$2" * -x mimetype   #1>/dev/null

Using SQLite database with OpenOffice.org

To use SQLite database with OpenOffice.org or LibreOffice:



In Office:

Connect to an existing database -> ODBC

View -> Data sources

View -> Data sources

Bash script to play .m4v video and .ul audio together

So you have a lot of .m4v video files and a lot of .ul audio files with the same names. That, for example, might be a collection of  CCTV records, where the name of the file is the date and time of when the record was made. Now you would like to play them.

Create a bash script file in ~/bin, /usr/bin or similar directory. Paste the code inside. Add execution rights. Then run the script with .m4v video  file name as the only argument. The script will figure out name of the audio file on its own and afterwards it will play it all with a bunch of various parameters.

Let’s call it playit:

 mplayer -fps 25 -vf denoise3d=0:0:100:0 -cache 16000 -framedrop $videoFile -audiofile $audioFile -audio-demuxer rawaudio -rawaudio format=0x0007:channels=1:rate=8000

Later you can play all video files in the current directory with their accompanying audio files by means of another script, let’s call this one playall:

 for i in *.m4v; do
    playit $i

And another improvement. A script to look into all subdirectories of the current directory and play media found there. Useful if you have your packs of audio &  video files stored in timestamped directories. Let’s call this one playdirs:

for subDir in */; do
cd $subDir
cd $rootDir

And then yet another one. Play only files only in a single directory. That will be playdir:

 cd $subDir
 cd $rootDir

Installing XBM on Ubuntu

Installing XBMC (soon to be Kodi) media center software on an Ubuntu based system (Ubuntu, Mint etc. ):

  • sudo apt-get install python-software-properties pkg-config
  • sudo apt-get install software-properties-common
  • sudo add-apt-repository ppa:team-xbmc/ppa
  • sudo apt-get update
  • sudo apt-get install xbmc

Upgrading it some time later:

  • sudo apt-get update
  • sudo apt-get install xbmc

Removing it eventually, if the need will be:

  • sudo apt-get update
  • sudo apt-get remove xbmc*
  • sudo apt-get purge xbmc*

Convert ODT to PDF

Use LibreOffice (OpenOffice.org) in command line mode to convert all of the ODT files in the directory to PDF files in subdirectory PDF:

  • libreoffice --headless --convert-to pdf --outdir PDF ./*.odt


Use ./*.odt instead of simply *.odt, because otherwise the program will consider file names beginning with “-” to be an argument and will fail.

Monitor directory with inotify

You can use inotifywait to watch a directory (or a file for that matter) for changes and run some action when they happen.

A sample script, which watches for a new file to be created and prints only its name:


inotifywait -m -e create --format %f /tmp/mytestdir | while read FILE
  echo "$FILE"

Send message to system log

Send a message to the Linux system log from the command line:

  • logger "Hello World!"


You can follow the messages logged to the system log by running:

  • tail -f /var/log/syslog


Get every new post delivered to your Inbox.