Created
June 11, 2023 03:58
-
-
Save laffan/20db23d2c6248bcf7265653438afead2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
# noCommentWordCount | |
# ------------------ | |
# This script searches your vault for a filename and | |
# returns the wordcount, not including text that is | |
# commented out | |
# ------------------ | |
# Usage : ./wordCount "First Year Exam Draft" | |
rootPath="/Users/usename/route/to/your/vault/" | |
echo -e ">> Word Count" | |
if ( test -z "$1" ) | |
then | |
echo -e "🚨 No file specified" | |
exit 1 | |
fi | |
filePath=$(find "$rootPath" -type f -name "$1.md") | |
if [ -z "$filePath" ]; then | |
echo -e "🚨 File not found" | |
exit 1 | |
fi | |
fileDir=${filePath%/*} | |
perl -0777 -pe 's/%%.*?%%//sg' "$filePath" | grep -oE '\w+' | wc -l | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment