I have this dir structure:
ParentDir
|
-- Child Dir1
|
-- File One.txt
-- File
|
-- Child Dir2
|
-- File Two.txt
-- File
I'm trying to find out all the .txt
files and count the sum total of number of lines in them, so I do something like this:
TXTFILES=$(find . -name '*.txt')
cat $TXTFILES | wc -l
but the problem is, I get,
cat: ./Child: No such file or directory
cat: Dir2/File: No such file or directory
cat: Two.txt: No such file or directory
cat: ./Child: No such file or directory
cat: Dir1/File: No such file or directory
cat: One.txt: No such file or directory
How do I handle spaces in the Dir & File names in such a situation? Is it possible without using a loop?