you can do this by using word count cmmand:
wc -l <filename>
output the number of lines in <filename> using:
$ wc -l /dir/file.txt
3272485 /dir/file.txt
Or, to omit the <filename> from the result use wc -l < <filename>:
$ wc -l < /dir/file.txt
3272485
You can also do this while piping data to wc as well:
$ cat /dir/file.txt | wc -l
3272485
$ curl yahoo.com --silent | wc -l
63