Skip to content

Instantly share code, notes, and snippets.

@trstephen
Created February 21, 2016 20:31
Show Gist options
  • Save trstephen/aea34ecbf1db8e1ec758 to your computer and use it in GitHub Desktop.
Save trstephen/aea34ecbf1db8e1ec758 to your computer and use it in GitHub Desktop.
Breaks multi sentence lines into single sentence lines.
#!/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