#!/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