Last active
September 2, 2021 13:24
-
-
Save asakura42/c1ffb6082e4ca47e3a51640633a3e7bd to your computer and use it in GitHub Desktop.
catt
This file contains 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 | |
case "$1" in | |
*.pdf) | |
exec pdftotext -layout "$1" - | |
;; | |
*.xl[ast][xmt]) | |
exec unzip -qc "$1" *.xml | sed -e 's/<\/[vft]>/\n/g; s/<[^>]\{1,\}>//g; s/[^[:print:]\n]\{1,\}//g' | |
;; | |
*.xlsb) | |
unzip -qc "$1" *.bin | strings -e l | |
;; | |
*.xl[wsrta]) | |
exec strings "$1" | |
;; | |
*.do[ct]) | |
exec catdoc -m160 "$1" | |
;; | |
*.do[tc][xm]) | |
exec unzip -qc "$1" word/document.xml | sed -e 's/<\/w:p>/\n/g; s/<[^>]\{1,\}>//g; s/[^[:print:]\n]\{1,\}//g' | |
;; | |
*.p[po]t) | |
exec strings -d "$1" | |
;; | |
*.p[po]t[xm]) | |
exec unzip -qc "$1" ppt/slides/*.xml | sed -e 's/<\/a:t>/\n/g; s/<[^>]\{1,\}>//g; s/[^[:print:]\n]\{1,\}//g' | |
;; | |
*.html) | |
exec cat "$1" | w3m -T text/html -dump -cols 250 | |
;; | |
*.epub) | |
exec unzip -qc "$1" *.*htm* | w3m -T text/html -dump -cols 250 | |
;; | |
*.chm) | |
exec 7z e -r -so "$1" *.*htm* | w3m -T text/html -dump -cols 250 | |
;; | |
*) | |
case $(file "$1") in | |
*Zstandard*) | |
exec pzstd -cdq "$1" | |
;; | |
*) | |
exec cat "$1" | |
;; | |
esac | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment