The last line of your file is probably missing the end of a new line. IIRC, wc -l just counts the number of newlines in a file.
If you try: cat -A file.txt | tail cat -A file.txt | tail , does your last line contain the terminating dollar sign ( $ )?
EDIT:
Assuming there is no newline in the last line of your file, you can add a newline to correct it as follows:
printf "\n" >> file.txt
The results of wc -l should now be consistent.
Steve Sep 27 '12 at 7:22 2012-09-27 07:22
source share