Download only the header of binary files from an FTP

Viewed 377

I have access to a public ftp server that contains several thousands of large binary file. I'm able to download all the files of a given folder with wget but this is time consuming and takes a lot of space on my disk. I actually only need to get the header of each file (the first 380 bytes). The header of the file contains metadata that will enable me to cherry-pick the files I need. The rest of the files is "only" the payload.

I would like to download very quickly, with wget or curl (or any other way) the first 380 bytes of each file from this server. According to this Q I tried to download a single file:

curl --header "Range: bytes=0-380" ftp://url/file.ext --output test.ext

But this actually downloads the whole file.

1 Answers

curl has --range/-r switch, which is documented to support even FTP protocol:

curl --range 0-380 ftp://example.com/file.ext --output test.ext

Regarding your attempt with --header:
FTP protocol has no headers. --header switch is for HTTP only.

wget does not seem to support ranges with FTP protocol.

Related