Skip to content

Instantly share code, notes, and snippets.

@bhpayne
Last active April 13, 2020 19:16
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 bhpayne/fb63fa0816be63733488162baebf9b14 to your computer and use it in GitHub Desktop.
Save bhpayne/fb63fa0816be63733488162baebf9b14 to your computer and use it in GitHub Desktop.
function lcount() {
count_py_files=`find . -type f | grep \.py$ | wc -l`
count_c_files=`find . -type f | grep \.c$ | wc -l`
count_csv_files=`find . -type f | grep \.csv$ | wc -l`
count_png_files=`find . -type f | grep \.png$ | wc -l`
count_html_files=`find . -type f | grep \.html$ | wc -l`
count_sh_files=`find . -type f | grep \.sh$ | wc -l`
count_xml_files=`find . -type f | grep \.xml$ | wc -l`
py_line_count=`find . -name "*.py" -type f -exec grep . {} \; | sed -n '/^# /!p' | wc -l`
tex_line_count=`find . -name "*.tex" -type f -exec grep . {} \; | sed -n '/^% /!p' | wc -l`
html_line_count=`find . -name "*.html" -type f -exec grep . {} \; | wc -l`
sh_line_count=`find . -name "*.sh" -type f -exec grep . {} \; | wc -l`
xml_line_count=`find . -name "*.xml" -type f -exec grep . {} \; | wc -l`
echo "{'hash':'$1', 'date':'$2', 'python file count':${count_py_files}, 'c file count':${count_c_files}, 'csv file count':${count_csv_files}, 'png file count':${count_png_files}, 'html file count':${count_html_files}, 'sh file count':${count_sh_files}, 'xml file count':${count_xml_files}, 'python line count':${py_line_count}, 'tex line count':${tex_line_count}, 'html line count':${html_line_count}, 'sh line count':${sh_line_count}, 'xml line count':${xml_line_count}}"
}
@bhpayne
Copy link
Author

bhpayne commented Apr 13, 2020

bash function which takes two arguments and returns a dict of line counts and file counts

lcount "asdasdfa" "April 2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment