Remove old fsub

This commit is contained in:
Augusto Gunsch 2021-11-29 21:33:34 -03:00
parent 5fa0aca52c
commit 9b3ba123f6
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
1 changed files with 0 additions and 59 deletions

View File

@ -1,59 +0,0 @@
#!/bin/sh
set -e
FSUBRC=~/.config/fsubrc
usage() {
echo "usage: fsub <files>"
echo "fsub expects $FSUBRC to have a blacklist of words"
exit 1
}
[ -z "$1" ] && usage
for arg in "$@"; do
case "$arg" in
*.srt )
if [ ! -f "$arg" ]; then
echo "$arg is not a file"
usage
fi ;;
*) echo "$arg is not a .srt file"; usage ;;
esac
done
[ -f "$FSUBRC" ] || touch $FSUBRC
for arg in "$@"; do
awk '
BEGIN {
n = 1
i = 0
while(getline < "'$FSUBRC'") {
blacklist[i] = $0
i++
}
}
/^[[:digit:]]+[[:space:]]*$/ {
getline
time = $0
linen = 0
while(getline) {
lines[linen] = $0
linen++
if($0 ~ /^[[:space:]]*$/) break
}
for(j = 0; j < i; j++)
for(k = 0; k < linen; k++)
if(lines[k] ~ blacklist[j]) next
print n
n++
print time
for(j = 0; j < linen; j++)
print lines[j]
}' "$arg" | sed 's/\r//' > /tmp/fsub
mv /tmp/fsub "$arg"
done