Skip to content

Instantly share code, notes, and snippets.

@carlok
Created July 4, 2019 19:18
Show Gist options
  • Save carlok/912dcd3a2a46b7ed9c2bc83536b34afe to your computer and use it in GitHub Desktop.
Save carlok/912dcd3a2a46b7ed9c2bc83536b34afe to your computer and use it in GitHub Desktop.
Counting the number of textual files and their number of lines
find A_LIST_OF_FOLDERS_AND_FILES -type f -exec grep -Iq . {} \; -print | wc -l
# A_LIST_OF_FOLDERS_AND_FILES => use the previous command as: find a b.txt c where a and c are directories or files
for a in $(find src -type f -exec grep -Iq . {} \; -print); do wc -l $a; done | awk '{split($0,a," "); sum += a[1]} END {print sum}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment