• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

URGENT: Help

CaptainKahuna

Platinum Member
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!
 
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.

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

 
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'
 
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?
 
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)
 
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. 🙂
 
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?

 
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!
 
Back
Top