Skip to content

Instantly share code, notes, and snippets.

@JonathanMH
Created November 18, 2012 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathanMH/4104830 to your computer and use it in GitHub Desktop.
Save JonathanMH/4104830 to your computer and use it in GitHub Desktop.
Count your characters from the Terminal
#!/bin/bash
pages_requested=10
characters_per_page=2400
files=( "code.md" "interface_design.md" "project_management.md" )
function countcompare {
images=`grep -c '.png' $1`
chars=`wc -c $1 | awk '{split($0,array," ")} END{print array[1]}'`
chars_with_images=$((chars+images*700))
chars_required=$(($pages_requested * $characters_per_page))
chars_to_go=$(($chars_required - $chars_with_images))
percentage_done=$(echo "scale=2; $chars_with_images / $chars_required * 100" | bc)
echo $percentage_done'% done of' $1
echo $chars_with_images of $chars_required
echo $(($images*700)) from $images images
echo $chars_to_go 'to go'
echo ''
}
echo '# # # # # # # # # # # # # # # # # # # # # # # # #'
for file in ${files[@]}
do
countcompare $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment