LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 04-29-2006, 12:57 PM   #1
sqrt7744
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Rep: Reputation: 0
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.

Thanks for any help...
 
Old 04-29-2006, 01:27 PM   #2
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
`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.
 
Old 04-29-2006, 02:16 PM   #3
sqrt7744
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Original Poster
Rep: Reputation: 0
nice, but...

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...

any ideas?
Thanks alot!
 
Old 04-29-2006, 03:01 PM   #4
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
You could do it the other way round: take the size of your file, take the size of the original iso, and the difference should be your offset (skip=).
 
Old 04-29-2006, 03:23 PM   #5
sqrt7744
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Original Poster
Rep: Reputation: 0
ahhh... if only i knew!

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)

thanks for the swift responses!
 
Old 04-29-2006, 03:30 PM   #6
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
You could use `xxd isofile > dumpfile` to create a text representation of your file and use a normal text editor to find your pattern.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
accidentally del /etc/group file in RedHat 9 karmakid Linux - Security 3 08-02-2005 08:16 PM
Help needed to recover data from ext3 file system where mkfs was issued accidentally kapilsampath Linux - General 4 04-26-2005 07:52 AM
Log failures to a separate file nielchiano Linux - General 0 02-17-2004 03:59 PM
Accidentally cleared the password file ForumKid Linux - General 8 03-04-2003 04:01 PM
saving log information to a separate file cuss Linux - General 2 02-24-2003 11:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration