Created
February 26, 2025 04:51
-
-
Save jakerieger/231ec94ba95f6994b213689dbb93e893 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
source_dirs=(dir1 dir2 dir3) | |
total=0 | |
root_dir=$(pwd) | |
for dir in "${source_dirs[@]}"; do | |
full_dir="$root_dir/$dir" | |
cd $full_dir | |
cpp_lines=$(find . -name '*.cpp' | xargs -I {} cat {} | wc -l) | |
hpp_lines=$(find . -name '*.hpp' | xargs -I {} cat {} | wc -l) | |
dir_total=$((cpp_lines + hpp_lines)) | |
echo "$full_dir: $dir_total lines" | |
total=$((total + cpp_lines + hpp_lines)) | |
cd $root_dir | |
done | |
echo "" | |
echo "Total: $total lines" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple bash script that will iterate over a list of directories and count up how many lines of code are in the source files with the provided extensions (
.cpp
and.hpp
in this case). Very slow.