Skip to content

Instantly share code, notes, and snippets.

@nonstriater
Last active July 27, 2020 05:55
Show Gist options
  • Save nonstriater/62c96681a4b4d036ce3daf6f6d3ee945 to your computer and use it in GitHub Desktop.
Save nonstriater/62c96681a4b4d036ce3daf6f6d3ee945 to your computer and use it in GitHub Desktop.
统计代码行数
#!/bin/sh
homeDir=$1
#cd /Users/ranwenjie/Desktop/c:c++/Bitcoin-xcode/bitcoin/src
cd $homeDir
# 目录内的源码统计
echo "" > /tmp/1.txt
find . -maxdepth 1 -type d -print0 | while read -d '' -r dir; do
files=("$dir"/*)
sum=`find $files -regex '.*\.\(cpp\|c\|h\)' -type f -print0 | xargs -0 wc -l | sort -nr | head -n 1 | awk '{print $1}'`
printf "%-20s %s \n" "$dir" "$sum" >> /tmp/1.txt
done
sort -k 2 -nr < /tmp/1.txt
# src目录下的源码统计
find ./ -maxdepth 1 -regex '.*\.\(cpp\|c\|h\)' -type f -print0 | xargs -0 wc -l | sort -nr | head -n 1 | awk '{print $1}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment