How to Combine Two Downloaded Files When wget Fails Halfway Through
From HowToGeek
Have you ever had the situation where you tried to download files using the wget utility on Linux, and then the transfer fails? It will try again to download the file, and then you'll have two parts of the full file.
Here's the scenario:
[root@ott1 transfer]# wget http://www.somesitenamehere.com/transferfiles/backupfile1.tar.gz --22:28:17-- http://www.somesitenamehere.com/transferfiles/backupfile1.tar.gz Resolving www.somesitenamehere.com... 72.47.237.65 Connecting to www.somesitenamehere.com|72.47.237.65|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1396306559 (1.3G) [application/x-gzip] Saving to: `backupfile1.tar.gz' 13% [===========> ] 187,216,464 --.-K/s in 15m 35s 22:43:52 (196 KB/s) - Read error at byte 187216464/1396306559 (Connection timed out). Retrying. --22:43:53-- (try: 2) http://www.somesitenamehere.com/transferfiles/backupfile1.tar.gz Connecting to www.somesitenamehere.com|72.47.237.65|:80... connected. HTTP request sent, awaiting response... 206 Partial Content Length: 1396306559 (1.3G), 1209090095 (1.1G) remaining [application/x-gzip] Saving to: `backupfile1.tar.gz.1' 100%[++++++++++++=================================>] 1,396,306,559 19.0M/s in 3m 56s 22:47:48 (4.89 MB/s) - `backupfile1.tar.gz.1' saved [1396306559/1396306559]
Houston, we have a problem! The full file should be 1.3GB, but I have two parts of the file:
[root@ott1 transfer]# ls -l total 1364932 -rw-r--r-- 1 root root 187216464 Apr 3 22:28 backupfile1.tar.gz -rw-r--r-- 1 root root 1209090095 Apr 3 22:24 backupfile1.tar.gz.1
So in this scenario, what you do is use the cat command to combine the two files, or you can combine many files this way. Just follow a similar syntax to this:
cat backupfile1.tar.gz backupfile1.tar.gz.1 > fullbackup.tar.gz
At this point, you should have the full file back together.
