Created
February 21, 2016 20:31
-
-
Save trstephen/aea34ecbf1db8e1ec758 to your computer and use it in GitHub Desktop.
Breaks multi sentence lines into single sentence lines.
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/bash | |
# | |
# Breaks multi sentence lines into single sentence lines. | |
# | |
# Usage: breaksentence *.tex; breaksentence foo.txt | |
replace_period_space_upper() { | |
# catches ". W" and ". W" where W = upper case word | |
# with OSX, it's necessary to use a linebreak instead of \n | |
# TODO: rewrite this with awk to get a substitution count | |
sed -i '' 's/\(\.[[:space:]]*\)\([[:upper:]]\)/.\ | |
\2/g' $1 | |
} | |
find "$@" -print0 | while read -d $'\0' file | |
do | |
echo -n "Replacing in ${file##*/} ... " | |
replace_period_space_upper $file | |
echo "done!" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment