Skip to content

Instantly share code, notes, and snippets.

@m-esm
Last active March 14, 2019 01:01
Show Gist options
  • Save m-esm/7e4c71f41986577976e01a9e84866710 to your computer and use it in GitHub Desktop.
Save m-esm/7e4c71f41986577976e01a9e84866710 to your computer and use it in GitHub Desktop.
count total lines of code in a directory - linux bash
for type in ts css html less json; do
echo "total lines of .$type files";
lines=$(( find ./ -path './*/node_modules' -prune -o -name "*.$type" -print0 | xargs -0 cat ) | wc -l);
echo "$lines";
done;
# example output:
# total lines of .ts files
# 34377
# total lines of .css files
# 10423
# total lines of .html files
# 125003
# total lines of .less files
# 14517
# total lines of .json files
# 519477
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment