UNIX Query About wc -l output

I was performing the wc -l operation in one data file the result is less when i was giving -nu on the view of the file.

while giving wc -l the count is 5023
after setting line numbers in view of file is giving 5024.
Can anyone help on this....

what is su -n ?

wc -l will count the newline character in a file

it is -nu in view mode of file which will give us the line number for each line in the file. I hope i am right here..

what is the last number of this command

cat -n filename | tail
cat -n filename | tail

It is giving 5424.

 wc -l is giving 5423 

I have one more doubt..
The first line itself is having lots of spaces.so in normal look it looks like second line which have no records..

will this can cuase the issue.

seems, your last line doesnt have the \n (new line character). So wc -l returns one less

 
tail -1 filename | od -c

execute the above command, and check whether you have \n in the output or not

---------- Post updated at 04:34 PM ---------- Previous update was at 04:32 PM ----------

 
$ echo "TEST" | wc -l
       1
$ echo -n "TEST" | wc -l
       0