I need to count all lines of an unix file. The file has 3 lines but wc -l
gives only 2 count.
I understand that it is not counting last line because it does not have end of line character
Could any one please tell me how to count that line as well ?
It is better to have all lines ending with EOL \n
in Unix files. You can do:
{ cat file; echo ''; } | wc -l
Or this awk:
awk 'END{print NR}' file