У меня работает в bash:
lines=100; { read header && sed "1~$((${lines}-1)) s/^/${header}\n/g" | split -l $lines --numeric-suffixes=1 --additional-suffix=.txt - file_ ; } < inputfile.txt
Многие (не все) сайты указывают размер в поле Content-Length
заголовки. Вы можете получить эту информацию с помощью wget -S
, но, похоже, у него нет возможности подавить загрузку. curl -D
также сделает это.
Однако вы можете получить только заголовки с помощью lynx, например,
$ lynx -dump -head http://speedtest.netcologne.de/test_100mb.bin
HTTP/1.1 404 Not Found
Server: nginx/1.6.2
Date: Sat, 13 Aug 2016 14:35:45 GMT
Content-Type: text/html
Content-Length: 168
Connection: close
, который менее подробен, чем wget
:
$ wget -S http://speedtest.netcologne.de/test_100mb.bin
--2016-08-13 10:29:51-- http://speedtest.netcologne.de/test_100mb.bin
Resolving speedtest.netcologne.de (speedtest.netcologne.de)... 78.35.18.142
Connecting to speedtest.netcologne.de (speedtest.netcologne.de)|78.35.18.142|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 404 Not Found
Server: nginx/1.6.2
Date: Sat, 13 Aug 2016 14:29:51 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive
2016-08-13 10:29:51 ERROR 404: Not Found.
Указанный URL не работает. Для действующего сайта происходит больше:
$ lynx -head -dump http://unix.stackexchange.com
HTTP/1.1 200 OK
Cache-Control: public, max-age=60
Content-Length: 77651
Content-Type: text/html; charset=utf-8
Expires: Sat, 13 Aug 2016 14:39:01 GMT
Last-Modified: Sat, 13 Aug 2016 14:38:01 GMT
X-Frame-Options: SAMEORIGIN
X-Request-Guid: 4da57e2b-c682-4e63-8fad-9415b23cd43e
Accept-Ranges: bytes
Date: Sat, 13 Aug 2016 14:38:01 GMT
Via: 1.1 varnish
Connection: close
X-Served-By: cache-iad2627-IAD
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1471099081.842119,VS0,VE17
Vary: *
X-DNS-Prefetch-Control: off
Set-Cookie: prov=31367c00-2e03-4760-79fe-d4e13e52792e; domain=.stackexchange.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
по сравнению с
$ wget -S http://unix.stackexchange.com
--2016-08-13 10:38:51-- http://unix.stackexchange.com/
Resolving unix.stackexchange.com (unix.stackexchange.com)... 151.101.129.69, 151.101.193.69, 151.101.1.69, ...
Connecting to unix.stackexchange.com (unix.stackexchange.com)|151.101.129.69|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Cache-Control: public, max-age=60
Content-Type: text/html; charset=utf-8
Expires: Sat, 13 Aug 2016 14:39:51 GMT
Last-Modified: Sat, 13 Aug 2016 14:38:51 GMT
X-Frame-Options: SAMEORIGIN
X-Request-Guid: d7279b7d-1605-49dc-9851-4658308bf6b1
Content-Length: 77662
Accept-Ranges: bytes
Date: Sat, 13 Aug 2016 14:38:51 GMT
Via: 1.1 varnish
Connection: keep-alive
X-Served-By: cache-iad2633-IAD
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1471099131.339794,VS0,VE16
Vary: *
X-DNS-Prefetch-Control: off
Set-Cookie: prov=77b452f3-9269-f933-e756-b4eb3010dc30 domain=.stackexchange.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
Length: 77662 (76K) [text/html]
Saving to: `index.html.1'
100%[======================================>] 77,662 --.-K/s in 0.02s
2016-08-13 10:38:51 (3.54 MB/s) - `index.html.1' saved [77662/77662]