I'm trying to get the number of files in a directory tree.
The command find . -type f
lists the files each on new line when I run it but if I store the result of the command in a variable, it stores it all on one line when I then echo that variable.
So if I then want to count the number of files via a for cycle, I stumble across a problem with files that have blank spaces in their name.
So is there a way to store the output of the find command in a variable where each file name is on new line? That way by counting the number of lines, I will get the number of files.