file accidentally appended to itself, how to separate?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
file accidentally appended to itself, how to separate?
Hello gurus!
I have a problem: the transfer of a dvd iso was interrupted after 2 GB or so, and then continued and completed. Unfortunately, the "continuation" was actually just a new complete transfer appended to the preexisting incomplete file, so the final size is 6.7GB instead of 4.7GB. All the data is there, but the first 2GB is the incomplete transfer. Before I can do anything with the ISO I have to remove the redundant and incomplete first 2GB of the file. How could I do this? Due to time and bandwidth constraints it is not possible for me to begin the transfer anew.
`dd` is your friend. I'll show you on an example file, you'll have to adapt the figures to your case:
Code:
pu@slackw:~$ v DesktopBSD-1.0-x86-DVD.copy.iso
-rw-r--r-- 1 root root 1343262720 2006-04-12 15:28 DesktopBSD-1.0-x86-DVD.copy.iso
pu@slackw:~$ dd if=DesktopBSD-1.0-x86-DVD.copy.iso of=part1 bs=1024 count=500000
500000+0 records in
500000+0 records out
pu@slackw:~$ dd if=DesktopBSD-1.0-x86-DVD.copy.iso of=part2 bs=1024 skip=500000
811780+0 records in
811780+0 records out
pu@slackw:~$ cat part1 part2 > part3
pu@slackw:~$ cmp part3 DesktopBSD-1.0-x86-DVD.copy.iso
pu@slackw:~$ v part*
-rw-r--r-- 1 pu pu 512000000 2006-04-29 20:19 part1
-rw-r--r-- 1 pu pu 831262720 2006-04-29 20:20 part2
-rw-r--r-- 1 pu pu 1343262720 2006-04-29 20:22 part3
pu@slackw:~$
Of course you only need to create "part2". The other commands are there to show you that it actually works.
Thanks for the dd tip! only problem is:
I'm not exactly sure at what byte the good data starts... somwhere around 2GB. Is it possible to search the file to find the location X at which i should use
dd if=junkfile of=goodfile skip=X ?
I'm just not familiar enough with the commands i would need for this. something like searching for the iso header, or just a repeat of the first few MB's of the file around the 2GB mark...
what a happy place this world would be if i actually knew the exact file size! I like your difference suggestion, but i'm still missing that crucial piece of information... trouble is, I won't even be able to find out the true file size until Monday since the file was coming from an office in London.
In the mean time I used dd to make a file containing the first 10MB of the junkfile, and am now trying to figure out how to use grep to search the whole file for that 10MB data chunk and report the offset, but I can't get it to work yet... is there a better way? (I thinking of giving up and writing some C code to do it)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.