Created
November 18, 2012 12:03
-
-
Save JonathanMH/4104830 to your computer and use it in GitHub Desktop.
Count your characters from the Terminal
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 | |
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