Created
October 30, 2012 01:42
-
-
Save allejo/3977827 to your computer and use it in GitHub Desktop.
Total Number of Lines of a Given File Type in a Folder
This file contains 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
#!/bin/bash | |
if [ -z "$1" ] # Check if no argument was passed | |
then | |
echo "No extension specified." | |
exit | |
fi | |
# If someone passes * as an argument it'll pass all the | |
# files in the directory as arguments, so we just need | |
# check if another variable is set and we'll know | |
# whether more than one argument was passed | |
if [ "$2" ] | |
then | |
find . -name '*.*' | xargs wc -l | |
else | |
find . -name '*.'$1 | xargs wc -l | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment