Created
June 16, 2014 01:59
-
-
Save hanigamal/39154bac4f5ed1e9978b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
filename="$1" | |
extension=${filename##*.} | |
if [ ${extension} = "doc" ] | |
then | |
# Use cat doc for older document formats | |
catdoc "$filename" | |
else | |
# Unzip the docx file, and grab just the text with sed | |
# This also replaces opening <w:r> tags with newlines | |
# The final `sed G` double spaces the output | |
unzip -p "$filename" | grep '<w:r' | sed 's/<w:p[^<\/]*>/ \ | |
/g' | sed 's/<[^<]*>//g' | grep -v '^[[:space:]]*$' | sed G | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment