UNIX Toolkit: "strings", or, recovering a Steemit post from a Firefox Crash

in #technology7 years ago

Crashed_computer.jpg

Have you ever lost a Steemit post, just as you were about to hit POST? Great fun, isn't it! Well, it just happened to me. This time though, I fought back. And .. damn if I didn't win!

F%$#^@&!!!

A few hours ago, in the midst of writing a long Steemit post, Firefox dumped core (crashed) on me. The program crashed, and I was left with a binary file containing all the contents of memory, at the time it crashed. My post was gone: a full three pages of carefully crafted content. There is no "drafts" folder on Steemit, after all!

Fully annoyed at myself for not having saved my work, I revolted against the idea of losing it all. What about that core file? YEAH! WHAT ABOUT THAT CORE FILE!!

Firefox dropped core when it crashed .. and the core file contains everything in memory .. so .. it must be there! Right?!

"It's in the core file!! My work!! It's here!!"

First, I grepped (searched) the core file for a long word I knew to be in my post: HIT! But the surrounding text was unrelated. I tried a few more terms, but it was not going well. The core file is binary (largely composed of unreadable garbage), and it does not search very well. I was finding bits and pieces of things, but nothing I could extract.

Enter the utility: strings

Strings (available on all *nix platforms) is a utility to address just this issue. It will search a binary file for text strings and conveniently pull them out for you. I ran it against the core file and outputted the results to a temporary file. I then searched the file, and within seconds, I located ALL OF MY WORK, in one perfect chunk. I was able to cut and paste it out of the core file into a text editor, and within about five minutes, I'd restored the work to its full glory. The only thing wrong with the text was some line break issues. I cleaned those up, and I was good as new.

There you go. Your UNIX tip of the day. If something similar happens to you, remember the core file! Thanks to Reuben Strayer and Wikimedia for the photo.

And thanks to GNU for strings.
Way to go Richard.

Sort:  

Nice work, the quality of a programmer...
Persistent and prowess

I agree, though for me personally, it is more persistence than prowess! I've had the fortune of working with real programmers, and, well .. I've got a ways to go.