Last active
August 13, 2020 09:48
-
-
Save orumin/f85890d821aa1a9abee6a51a0949deb8 to your computer and use it in GitHub Desktop.
get Linux line of code
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
#/usr/bin/fish | |
curl -LO https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.8.tar.xz | |
tar -xJf linux-5.8.tar.xz | |
cd linux-5.8 | |
for i in ( find . -maxdepth 1 -type d ! \( -name '.*' -o -name 'Documentation' -o -name 'LICENSES' -o -name 'samples' -o -name 'scripts' -o -name 'tools' \) ) | |
echo $i; | |
cloc $i; | |
end > ../linux_loc.txt | |
echo (find . -maxdepth 1 -type d ! \( -name '.*' -o -name 'Documentation' -o -name 'LICENSES' -o -name 'samples' -o -name 'scripts' -o -name 'tools' \)) | read -a dirs | |
cd ../ | |
for i in (grep SUM linux_loc.txt | awk '{print $5}'); | |
echo -e "$dirs[$count]\t$i"; | |
set count (expr $count + 1); | |
end > loc.txt; | |
sort -r -n -k 2,2 loc.txt > loc_tmp.txt | |
awk 'NR==FNR{s=s+$2;next}{p=$2/s*100; print $0, "\t", p"%"}' loc_tmp.txt loc_tmp.txt > loc.txt | |
rm loc_tmp.txt | |
echo -e "total line\t"(awk '{s += $2} END {print s}' < loc.txt) >> loc.txt |
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
./drivers 13048806 69.1353% | |
./arch 1782710 9.44517% | |
./fs 967163 5.12423% | |
./sound 935637 4.9572% | |
./net 828886 4.39161% | |
./include 644501 3.4147% | |
./kernel 237713 1.25945% | |
./lib 131807 0.698341% | |
./mm 91805 0.486402% | |
./crypto 83988 0.444986% | |
./security 67041 0.355197% | |
./block 37711 0.199801% | |
./ipc 6689 0.0354397% | |
./virt 5234 0.0277308% | |
./init 3309 0.0175318% | |
./usr 867 0.00459355% | |
./certs 442 0.00234181% | |
total l18874309 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment