How to get "wc -l" to print just the number of lines without file name?
Try this way:
wc -l < file.txt
cat file.txt | wc -l
According to the man page (for the BSD version, I don't have a GNU version to check):
If no files are specified, the standard input is used and no file name is displayed. The prompt will accept input until receiving EOF, or [^D] in most environments.
To do this without the leading space, why not:
wc -l < file.txt | bc