When I'm saying something like
and I want to read only n first lines, how do I do that? I know that's something like:
curl http://example.com/123 | ???
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
curl in particular, there is an option to only load a range of bytes. Because it's bytes instead of lines, you may need to overestimate and then trim with head or tail, but this might save load-time on long webpages (or the byte-range may be sufficient for your application.) For example,
curl --range 0-99 http://example.com/123
will get the first 100 bytes. (You can also pull out a range in the middle of the page, give multiple disjoint ranges, or use a range measured from the end of the page.)
(I don't know for sure, but I think curl will load the whole webpage even if it's piped to a command that only reads the first few lines.)