Created
December 27, 2022 08:57
-
-
Save ifgeny87/0cb86c988e538c03551e28e297669a68 to your computer and use it in GitHub Desktop.
Count files and lines
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
| ALL1f=0 | |
| ALL1l=0 | |
| ALL2f=0 | |
| ALL2l=0 | |
| ALL3f=0 | |
| ALL3l=0 | |
| wk() { | |
| # подсчет количества файлов, строк, слов и символов в найденных файлах | |
| lines=$(find "$1" -name "$2") | |
| if [ -z "$lines" ]; then echo "0 0 0 0" | |
| else wc $lines | awk '{ if ($4 == "total"); else { k++; l+=$1; w+=$2; c+=$3 } } END { print k, l, w, c }' | |
| fi | |
| } | |
| pri() { | |
| printf '\e[36m%-16s\e[m | %3d %6d | %8d %6d | %13d %6d\n' "$1" $2 $3 $4 $5 $6 $7 | |
| } | |
| count() { | |
| k=$(wk "$1" '*.ts') | |
| IFS=' ' read -r -a K1 <<< $k # разбиваем на массив | |
| k=$(wk "$1" 'index.ts') | |
| IFS=' ' read -r -a K2 <<< $k # разбиваем на массив | |
| # K1=$(find $1 -name '*.ts' | wc -l | sed 's/ *//g') | |
| # K2=$(find $1 -name 'index.ts' | wc -l | sed 's/ *//g') | |
| K3f=$((K1[0] - K2[0])) | |
| K3l=$((K1[1] - K2[1])) | |
| ALL1f=$((ALL1f + K1[0])) | |
| ALL1l=$((ALL1l + K1[1])) | |
| ALL2f=$((ALL2f + K2[0])) | |
| ALL2l=$((ALL2l + K2[1])) | |
| ALL3f=$((ALL3f + K3f)) | |
| ALL3l=$((ALL3l + K3l)) | |
| pri "$1" ${K1[0]} ${K1[1]} ${K2[0]} ${K2[1]} $K3f $K3l | |
| } | |
| echo "Folder | All, lines | index.ts, lines | without index, lines" | |
| echo "-----------------|------------|-----------------|---------------------" | |
| count "src/enums" | |
| count "src/factories" | |
| count "src/models" | |
| count "src/serializers" | |
| count "src/utils" | |
| count "tests" | |
| pri '--------- total:' $ALL1f $ALL1l $ALL2f $ALL2l $ALL3f $ALL3l | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment