I have a text file which has over 60MB size. It has got entries in 5105043 lines, but when I am doing wc -l it is giving only 5105042 results which is one less than actual. Does anyone have any idea why it is happening?
Is it a common thing when the file size is large?
wc stands for word count. As the name implies, it is mainly used for counting purpose. It is used to find out number of lines, word count, byte and characters count in the files specified in the file arguments. By default it displays four-columnar output.
sure it does, you just pass in the proper parameters that you would anyway. for example, if you do wc -c < file name , it will give you just the integer number of bytes and nothing else.
The “wc” or the word count command in Bash is considered extremely useful as it helps in finding out various statistics of a file. This command can be used in multiple different variations.
-l Option. Display the number of lines in the file.
Last line does not contain a new line.
One trick to get the result you want would be:
sed -n '=' <yourfile> | wc -l
This tells sed
just to print the line number of each line in your file which wc
then counts. There are probably better solutions, but this works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With