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
Post a Comment