1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Cape Town
    Rep Power

    Wget last part of a file?

    Is it possible to just download last part of a huge file so as to tail it? I need to save bandwidth.
    Can wget do it or what can do it?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2006
    Rep Power
    You could 'blag it' - create a dummy file at your end of the size less how much you want, the use the -c (continue option)?

    So, say the file you want is 100MB but all you want is the last 1MB, create a file 99M in size wiht the same name as the file you want (mkfile -n 99M MyWantedFile)
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Rep Power
    Or use curl.
    -C/--continue-at <offset>
    Continue/Resume a previous file transfer at the given offset. The given offset is the exact number of bytes that will be skipped, counting from the beginning of
    the source file before it is transferred to the destination. If used with uploads, the FTP server command SIZE will not be used by curl.

    Use "-C -" to tell curl to automatically find out where/how to resume the transfer. It then uses the given output/input files to figure that out.

    If this option is used several times, the last one will be used.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Bonita Springs, FL
    Rep Power
    Note the ability for either wget or curl (or anything else) to download only the last part of a file depends on whether or not the server allows such an action. Depending on what you are trying to download, the server may not allow range requests and you'll get the entire file anyway. You also need to be able to calculate the desired offset which means you need to know how large the file is in the first place. You could possibly get this information with a HEAD request and look at the content length header.
    Recycle your old CD's

    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud

IMN logo majestic logo threadwatch logo seochat tools logo