config/scripts/docgrepfile

25 lines
566 B
Plaintext
Raw Permalink Normal View History

2018-04-27 15:39:33 +02:00
#!/bin/bash
file=$1
shift
if [[ ${file} == *.pdf ]]; then
pdfgrep -H "$@" "${file}"
elif [[ ${file} == *.doc ]]; then
grepoutput=$(catdoc "${file}" | grep -n --color "$@")
if [ $? -eq 0 ];then
echo "${file}:${grepoutput}"
fi
elif [[ ${file} == *.docx ]]; then
grepoutput=$(docx2txt < "${file}" | grep -n --color "$@")
if [ $? -eq 0 ];then
echo "${file}:${grepoutput}"
fi
elif [[ ${file} == *.odt ]]; then
grepoutput=$(odt2txt "${file}" | grep -n --color "$@")
if [ $? -eq 0 ];then
echo "${file}:${grepoutput}"
fi
else
grep -n --color $@ ${file}
fi