-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
158 additions
and
17 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.20180725 | ||
0.20180804 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.TH "FB2totxt User Manual" 0.20180804 "04 Aug 2018" "User documentation" | ||
|
||
.SH NAME | ||
fb2toinfo | ||
|
||
.SH DESCRIPTION | ||
Bash-script for console FB2 info reader | ||
|
||
.SH SYNOPSIS | ||
fb2totxt [options] book.fb2 | ||
|
||
.SH OPTIONS | ||
.TP | ||
-o name.txt | ||
name text file (default = stdout) | ||
.TP | ||
-z | ||
force unzip (default = false) | ||
.TP | ||
-h | ||
help | ||
|
||
.SH EXAMPLE | ||
fb2toinfo book.fb2.zip | ||
|
||
.SH COPYRIGHT | ||
Copyright 2018 zvezdochiot. | ||
All rights reserved. | ||
|
||
.SH SEE ALSO | ||
fb2encode, | ||
fb2totxt, | ||
fb2tozip, | ||
fb2xmlfix, | ||
sed, | ||
file, | ||
less, | ||
unzip, | ||
zcat | ||
|
||
.SH CONTACTS | ||
Website: https://github.com/zvezdochiot/bash-fb2 | ||
Email: [email protected] |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/sh | ||
|
||
#fb2toinfo.sh | ||
#Depends: dash, sed, file, unzip, zcat | ||
|
||
sname="Fb2toinfo" | ||
sversion="0.20180804" | ||
|
||
echo "$sname $sversion" >&2 | ||
|
||
tnocomp="" | ||
tcomp="sed" | ||
[ ! "$(command -v $tcomp)" ] && tnocomp="$tnocomp $tcomp" | ||
tcomp="file" | ||
[ ! "$(command -v $tcomp)" ] && tnocomp="$tnocomp $tcomp" | ||
tcomp="unzip" | ||
[ ! "$(command -v $tcomp)" ] && tnocomp="$tnocomp $tcomp" | ||
tcomp="zcat" | ||
[ ! "$(command -v $tcomp)" ] && tnocomp="$tnocomp $tcomp" | ||
if [ "+$tnocomp" != "+" ] | ||
then | ||
echo "Not found:${tnocomp}!" >&2 | ||
echo "" >&2 | ||
exit 1 | ||
fi | ||
|
||
fzip="false" | ||
fhlp="false" | ||
while getopts ":o:zh" opt | ||
do | ||
case $opt in | ||
o) dst="$OPTARG" | ||
;; | ||
h) fhlp="true" | ||
;; | ||
z) fzip="true" | ||
;; | ||
*) echo "Unknown option -$OPTARG" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift "$(($OPTIND - 1))" | ||
src="$1"; | ||
|
||
if [ "x$src" = "x" -o "x$fhlp" = "xtrue" ] | ||
then | ||
echo "Usage:" | ||
echo "$0 [options] book.fb2" | ||
echo "Options:" | ||
echo " -o name.txt name text file (default = stdout)" | ||
echo " -z force unzip (default = false)" | ||
echo " -h help" | ||
exit 0 | ||
fi | ||
|
||
if [ ! -f "$src" ] | ||
then | ||
echo "Not found $src!" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ "x$src" = "x$dst" ] | ||
then | ||
dst="$dst.txt" | ||
fi | ||
|
||
sedcmdf='s/<body>/\n&\n/;s/<\/body>/\n&\n/;' | ||
sedcmds='/<body/,$d;' | ||
sedcmdu='s/<[^>]+>//g;/^[[:space:]]*$/d' | ||
fcompr=$(file -b -i "$src") | ||
[ "x$fzip" = "xtrue" ] && fcompr="application/zip; charset=binary" | ||
[ "x$fgzip" = "xtrue" ] && fcompr="application/gzip; charset=binary" | ||
|
||
if [ "x$fcompr" = "xapplication/zip; charset=binary" ] | ||
then | ||
if [ -z "$dst" ] | ||
then | ||
unzip -c "$src" | sed -e "$sedcmdf" | sed -e "$sedcmds" | sed -r "$sedcmdu" | ||
else | ||
unzip -c "$src" | sed -e "$sedcmdf" | sed -e "$sedcmds" | sed -r "$sedcmdu" > "$dst" | ||
fi | ||
else | ||
if [ -z "$dst" ] | ||
then | ||
zcat "$src" | sed -e "$sedcmdf" | sed -e "$sedcmds" | sed -r "$sedcmdu" | ||
else | ||
zcat "$src" | sed -e "$sedcmdf" | sed -e "$sedcmds" | sed -r "$sedcmdu" > "$dst" | ||
fi | ||
fi |
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
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
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