I downloaded a JSON file using Curl on my server from https://api.data.gov/ed/collegescorecard/v1/schools?api_key=[my_API_key]
(I have uploaded the file to TinyUpload if you want to play around with it.)
The downloaded file is 1.5MB and has a very large (and valid) JSON object. However, on the server when I run the command wc -l
against the file, it returns 0. Running wc -c
returns the correct byte count.
I opened the file in TextEdit and it looked fine. I did notice that man wc
on my server (CentOS 5.5) and man wc
on my Mac (Yosemite) seem to have different descriptions for what the -l
flag does:
CentOS 5.5:
print the newline counts
OSX 10.10.5 Yosemite
The number of lines in each input file is written to the standard output.
Which manual is correct? Does wc -l
count lines or new lines? If it does count lines and not new lines, is there ever a case when wc -l
could return 0 even when there is a line in the file?
Is it also possible that Mark's comment regarding Windows based characters on this related SO post is the correct diagnoses? I ran cat -vet
against my file, but couldn't find ^M
using grep, and it's way too much text to manually search.
The manpage on OS X also says (first paragraph in the description):
A line is defined as a string of characters delimited by a < newline> character.
So there is no contradiction between the two versions of the mangpages.
Since your file does not have a newline, wc -l
correctly returns 0.