This command will return the number of total lines contained in files ending in .py in the directory it is run in, as well as subdirectories:
1 2 | find . -type f -iname *py | xargs -I str wc -l str | \ awk '{SUM += $1} END {print SUM}' |
Just change .py to whatever file type you want to get the count.
I wanted to add this as a Bash alias, passing in the filetype as an argument. This would make the whole affair much easier. But when I tried it as an alias, or as a function, I always got 0 back. Running “type” on the alias name returned:
1 2 | pylines is aliased to `find . -type f -iname *py | xargs -I str \ wc -l str | awk '{SUM += bell-style} END {print SUM}'' |
If anyone has any insight into this, please share.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.








