diff options
-rw-r--r-- | dehyphenate.sh | 6 | ||||
-rw-r--r-- | nonewlines.sh | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/dehyphenate.sh b/dehyphenate.sh index 5dae71b..7656476 100644 --- a/dehyphenate.sh +++ b/dehyphenate.sh @@ -5,4 +5,8 @@ Removes word-breaking hyphens from all .txt files in a directory." test $# -ne 1 && echo "$usage" && exit 1 -find "$1" -type f -name '*txt' -exec perl -0777pi -e 's/-\n(\S+)\s*/\1\n/smg' '{}' ';' +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 diff --git a/nonewlines.sh b/nonewlines.sh index e765d64..499b791 100644 --- a/nonewlines.sh +++ b/nonewlines.sh @@ -7,6 +7,6 @@ line breaks, saving the result to dirname.txt" test $# -ne 1 && echo "$usage" && exit 1 d=`dirname "$1"` -cat "$1"/*txt | tr -d '\n' > "${d}.txt" +cat "$1"/*.dehyphenated.txt | tr -d '\n' > "${d}.txt" echo "Saved all text, with no newlines, to ${d}.txt" |