summaryrefslogtreecommitdiff
path: root/dehyphenate.sh
blob: 7656476050eaa763e20f105609ceb83ad5633911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh
usage="Usage: $0 dir

Removes word-breaking hyphens from all .txt files in a directory."

test $# -ne 1 && echo "$usage" && exit 1

find "$1" -type f -name '*.txt' | while read i; do
	d=`dirname "$i"`
	b=`basename "$i" .txt`
	perl -0777p -e 's/-\n(\S+)\s*/\1\n/smg' "$i" > "$d/$b.dehyphenated.txt"
done