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.

Revisions

  1. nonstriater revised this gist Jul 27, 2020. No changes.
  2. nonstriater created this gist Jul 27, 2020.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/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}'