Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
astextplain34 linesDownload Raw Back to bin
1#!/bin/sh -e2# minimalistic replacement for `run-mailcap --action=cat <file>`3 4if test "$#" != 1 ; then5	echo "Usage: astextplain <file>" 1>&26	exit 17fi8 9# XXX output encoding (UTF-8) hardcoded10case "$(file --brief --mime-type "$1")" in11	application/vnd.oasis.opendocument.spreadsheet | application/vnd.oasis.opendocument.formula | application/vnd.oasis.opendocument.text)12		odt2txt "$1" || cat "$1"13		;;14	application/msword)15		out=$(antiword -m UTF-8 "$1") && sed "s/\^M$//" <<<$out || cat "$1"16		;;17	application/vnd.openxmlformats-officedocument.wordprocessingml.* | application/vnd.ms-word.*.macroenabled.12)18		docx2txt.pl "$1" - || cat "$1"19		;;20	application/pdf)21		out=$(pdftotext -q -layout -enc UTF-8 "$1" -) && sed "s/(\^M$)|(^\^L)//" <<<$out || cat "$1"22		;;23	# TODO add rtf support24	application/rtf | text/rtf | text/plain | inode/x-empty)25		cat "$1"26		;;27	*)28		echo "E: unsupported filetype $1" 1>&229		exit 130		;;31esac32 33exit 034 
codekingpro/portable-devtools · Team Ai