#!/bin/sh # convert a stdin-docx file to stdout-txt # use unoconv from unoconv package # TODO: handle unoconv deadlock (set a background and timeout) tmpfile=$(tempfile --suffix=.docx) || exit 1 tmpfile2=$(tempfile --suffix=.txt) || exit 1 trap "rm -f -- '$tmpfile' '$tmpfile2'" EXIT cat >>$tmpfile unoconv -d=document -f txt "$tmpfile" "$tmpfile2" || exit 1 cat "$tmpfile2" rm -f -- "$tmpfile" trap - EXIT exit 0