Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have only one row in my file. When I execute wc -c file1.txt the result is 200, while the output of wc -L file1.txt is 198. What explains the difference of 2?

share|improve this question

1 Answer 1

-L prints the length of the longest line. Your line must be 198 characters long. The two missing bytes are end of line and end of file characters.

share|improve this answer
    
Thanks Peter for your quick reply. I got your point. but do we have any option to set both results should be same for wc -c and wc -L. am i missing anything here.? –  abhilash May 8 at 14:27
1  
The two options are meant to provide different information. So, no, you cannot have the two give same result. –  unxnut May 8 at 14:29
    
Thank you both. the file which i shown is being loaded from one process(target). if i want to add/include end of line and end of file charector in the output file what should i do?. Any Idea –  abhilash May 8 at 15:25
3  
@abhilash Your question essentially was why the output of two different options to the wc program were different. I think that question has been answered. If you have another question, post another separately. This is not a discussion board. –  Benjamin B. May 8 at 15:42
1  
There is no character that represents "end of file". All you can safely say is that at least one is LF (newline) and that it follows 198 printable characters –  roaima May 8 at 18:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.