URGENT: Help

CaptainKahuna

Platinum Member
May 19, 2002
2,228
0
0
www.billda.com
I have a computer science program due tomorrow at noon which I've been up all night doing. Our teacher requires that we tar our files to send them in. My directory listing:

test1.txt
test2.txt
huffman.cpp

with huffman.cpp being my program.

I did the following:

tar -cf huffman.cpp test1.txt test2.txt

and I believe it created a tar OVER MY CPP FILE.

Is there any way to get it back??? Untarring didnt give me anything...

UPDATE:

Well guys, I couldn't recover any of my data, but thanks so much for the concern and help!

I was able to convince my professor to accept the binary only (which I still had) without any code. He only took off 5 points for lack of code.

I ended up with a 95% :) :beer:

Thanks again everyone, it's times like this I love AT!
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
You basically wrote over your file :(

Should have been

#> tar -cf name.tar files

You're not totally hopeless.. some editors keep temp files, often hidden dot files.

Check your home directory and whatever directory you were using for newest mod

#> ls -altr

if you're a really lucky guy there will be some .files with perhaps partial pieces of your code left, but this is hypothetical.

 

CaptainKahuna

Platinum Member
May 19, 2002
2,228
0
0
www.billda.com
I was using BBEdit, but I can't find any hidden files. *sob*

is there anyway to read the disk bitwise? the new tar file that over wrote it is about 2 lines of text, while the program was about 500
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
Well judging by the BBedit program I imagine you're programming on a Mac (FreeBSD mach micro kernel).

Try this for grins.

#> grep -a -B[size before] -A[size after] 'text' /dev/[your_partition]

Example, you want to undelete a file (+- 200 lines) starting with "xxx" stored on /dev/hda...

#> grep -a -B2 -A200 "xxx" /dev/hda1

you can then pipe that amount to a file by adding '> file.cpp' to the end of the last command.

That's the UNIX way, your results may vary.
 

CaptainKahuna

Platinum Member
May 19, 2002
2,228
0
0
www.billda.com
OK I got some results!

60042991345: totalHuffChars += freqTable[temp].huffCode.length();
60042991683: freqTable[myNode->asciiChar].huffCode = tempString;
60042992239: if (freqTable.occurances != 0)
60042992343: cout << '\t' << '\t' << freqTable.huffCode << endl;
60042993539: nodeArray->value = freqTable.frequency;
60042993876: freqTable[temp].occurances++;
60042994046: total += freqTable.occurances;
60042994249: freqTable.frequency = freqTable.occurances/total;
60042994311: if (freqTable.frequency < min && freqTable.frequency != 0.0)
60042994384: min = freqTable.frequency;
60042994559: if (freqTable.frequency == 0.0)
60042994744: if (freqTable.frequency == 0.0)
60042994785: freqTable.frequency = (min/k);
60042995252: if (freqTable.occurances != 0 && i != 10)
60042995303: cout << " " << i << '\t' << '\t'<< (char)i << '\t' << '\t' << freqTable.occurances << '\t' << '\t' << freqTable.frequency << endl;
60042995451: else if (freqTable.occurances != 0 && i == 10)
60042995507: cout << " " << i << '\t' << '\t' << "\\0" << '\t' << '\t' << freqTable.occurances << '\t' << '\t' << freqTable.frequency << endl;
60043035387:arrayEntry freqTable[128];
60043036401: totalHuffChars += freqTable[temp].huffCode.length();
60043036739: freqTable[myNode->asciiChar].huffCode = tempString;
60043037295: //if (freqTable.occurances != 0)
60043037401: cout << '\t' << '\t' << freqTable.huffCode << endl;
60043038597: nodeArray->value = freqTable.frequency;
60043038934: freqTable[temp].occurances++;
60043039104: total += freqTable.occurances;
60043039307: freqTable.frequency = freqTable.occurances/total;
60043039369: if (freqTable.frequency < min && freqTable.frequency != 0.0)
60043039442: min = freqTable.frequency;
60043039617: if (freqTable.frequency == 0.0)
60043039802: if (freqTable.frequency == 0.0)
60043039843: freqTable.frequency = (min/k);
60043040310: if (freqTable.occurances != 0 && i != 10)
60043040361: cout << " " << i << '\t' << '\t'<< (char)i << '\t' << '\t' << freqTable.occurances << '\t' << '\t' << freqTable.frequency << endl;
60043040509: else if (freqTable.occurances != 0 && i == 10)
60043040565: cout << " " << i << '\t' << '\t' << "\\0" << '\t' << '\t' << freqTable.occurances << '\t' << '\t' << freqTable.frequency << endl;

That's a bunch of my code, from toward the beginning of the file. How can I recover it?

 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
Originally posted by: CaptainKahuna
OK I got some results!

60042991345: totalHuffChars += freqTable[temp].huffCode.length();
60042991683: freqTable[myNode->asciiChar].huffCode = tempString;
60042992239: if (freqTable.occurances != 0)
60042992343: cout << '\t' << '\t' << freqTable.huffCode << endl;
60042993539: nodeArray->value = freqTable.frequency;
60042993876: freqTable[temp].occurances++;
60042994046: total += freqTable.occurances;
60042994249: freqTable.frequency = freqTable.occurances/total;
60042994311: if (freqTable.frequency < min && freqTable.frequency != 0.0)
60042994384: min = freqTable.frequency;
60042994559: if (freqTable.frequency == 0.0)
60042994744: if (freqTable.frequency == 0.0)
60042994785: freqTable.frequency = (min/k);
60042995252: if (freqTable.occurances != 0 && i != 10)
60042995303: cout << " " << i << '\t' << '\t'<< (char)i << '\t' << '\t' << freqTable.occurances << '\t' << '\t' << freqTable.frequency << endl;
60042995451: else if (freqTable.occurances != 0 && i == 10)
60042995507: cout << " " << i << '\t' << '\t' << "\\0" << '\t' << '\t' << freqTable.occurances << '\t' << '\t' << freqTable.frequency << endl;
60043035387:arrayEntry freqTable[128];
60043036401: totalHuffChars += freqTable[temp].huffCode.length();
60043036739: freqTable[myNode->asciiChar].huffCode = tempString;
60043037295: //if (freqTable.occurances != 0)
60043037401: cout << '\t' << '\t' << freqTable.huffCode << endl;
60043038597: nodeArray->value = freqTable.frequency;
60043038934: freqTable[temp].occurances++;
60043039104: total += freqTable.occurances;
60043039307: freqTable.frequency = freqTable.occurances/total;
60043039369: if (freqTable.frequency < min && freqTable.frequency != 0.0)
60043039442: min = freqTable.frequency;
60043039617: if (freqTable.frequency == 0.0)
60043039802: if (freqTable.frequency == 0.0)
60043039843: freqTable.frequency = (min/k);
60043040310: if (freqTable.occurances != 0 && i != 10)
60043040361: cout << " " << i << '\t' << '\t'<< (char)i << '\t' << '\t' << freqTable.occurances << '\t' << '\t' << freqTable.frequency << endl;
60043040509: else if (freqTable.occurances != 0 && i == 10)
60043040565: cout << " " << i << '\t' << '\t' << "\\0" << '\t' << '\t' << freqTable.occurances << '\t' << '\t' << freqTable.frequency << endl;

That's a bunch of my code, from toward the beginning of the file. How can I recover it?




Awesome :)

Glad it worked for you.

You'll want to probably adjust the line from 200 to something bigger or smaller depending on how much you need more and then run this command I mentioned earlier:

#> grep -a -B2 -A200 "xxx" /dev/hda1 > file.cpp

This will redirect the output of the grep command to the file 'file.cpp'
 

Koing

Elite Member <br> Super Moderator<br> Health and F
Oct 11, 2000
16,843
2
0
Originally posted by: cyclohexane
the power of ATOT is astounding

:)

It is very good indeed :thumbsup:

Koing
 

CaptainKahuna

Platinum Member
May 19, 2002
2,228
0
0
www.billda.com
Originally posted by: chuckywang
OP: What did you replace the 'xxx' with?

I replaced it with 'freqTable' - the name of one of my arrays in the program.

Does anyone have any idea how I can recover the lines surrounding those? Those lines that do not necissarily contain 'freqTable', but are still the rest of my code?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
This is one reason why we make backups.

Backups are your friend.

What other data do you care about that you only have 1 copy of? When the hard drive on your PC dies, how much will you lose?

(Just saying this is something you should learn from and apply to the rest of your e-life)
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
Originally posted by: CaptainKahuna
Originally posted by: chuckywang
OP: What did you replace the 'xxx' with?

I replaced it with 'freqTable' - the name of one of my arrays in the program.

Does anyone have any idea how I can recover the lines surrounding those? Those lines that do not necissarily contain 'freqTable', but are still the rest of my code?

The best way is to search a string you know will be at the very beginning of your code.. for example I always use a standard comment block, etc. Then, adjust the # of lines AFTER that line down until you have the entire output.

I also suggest NOT writing anything to disk until you do this. :)
 

skyking

Lifer
Nov 21, 2001
22,889
6,056
146
Originally posted by: Platypus
Originally posted by: CaptainKahuna
Originally posted by: chuckywang
OP: What did you replace the 'xxx' with?

I replaced it with 'freqTable' - the name of one of my arrays in the program.

Does anyone have any idea how I can recover the lines surrounding those? Those lines that do not necissarily contain 'freqTable', but are still the rest of my code?

The best way is to search a string you know will be at the very beginning of your code.. for example I always use a standard comment block, etc. Then, adjust the # of lines AFTER that line down until you have the entire output.

I also suggest NOT writing anything to disk until you do this. :)
The output portion of that, does it do a write in the directory you are in, for that>file.cpp?
Is there a chance that will write over some of his lost file?

 

CaptainKahuna

Platinum Member
May 19, 2002
2,228
0
0
www.billda.com
Well guys, I couldn't recover any of my data, but thanks so much for the concern and help!

I was able to convince my professor to accept the binary only (which I still had) without any code. He only took off 5 points for lack of code.

I ended up with a 95% :)

Thanks again everyone, it's times like this I love AT!