Is this the correct way to show the line count of a specific file?
cat file | grep * -c
You can use this command:
This will return the total line number count in the provided file.
Your shell will "expand" the asterisk in
Which is not what you want.
If the input is a file, however, you may consider giving access to the file instead of piping it on stdin, to the command that does the counting. (for example
If you don't want
Number all non-empty lines:
Or include everything: