bash - The wc -l gives wrong result -


i got wrong result wc -l command. after long :( checking found core of problem, here simulation:

$ echo "line end" > file $ echo -n "line without end" >>file $ wc -l file        1 file 

here 2 lines, missing last "\n". easy solution?

for wc line ends "\n" char. 1 of solutions grep-ing lines. grep not looking ending nl.

e.g.

$ grep -c . file        #count occurrence of character 2 

the above not count empty lines. if want them, use the

$ grep -c '^' file      #count beginnings of lines 2 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -