I have a few hundred txt files in several subfolders and I would like the count the lines in each txt file. I can do this for all txt files in the current directory by using:
for f in *.txt; do wc -l "$f"; done
[number] [txt filename] [number] [txt filename] [number] [txt filename]
Which is good. However, I don't want to to do this hundreds of times, navigating to each subfolder. The directory structure is:
-main -folder1 textfile1.txt textfile2.txt textfile3.txt -folder2 textfile4.txt textfile5.txt textfile6.txt -folder3 textfile7.txt textfile8.txt textfile9.txt ...and so forth
Of note, the text files contain spaces and several dots before the .txt extension. Using the wc -l up above as written didn't produce any errors, though. Using terminal on a Mac running MacOS, which behaves like BSD for the most part.