1752751 Members
5098 Online
108789 Solutions
New Discussion юеВ

Re: sed gzipped files

 
Ken Tiernan
New Member

sed gzipped files

Greetings,

Our vendors tech support person executed sed "s/$/6|/" filename.gz and screwed up some files.

Does anyone know how I can reverse sed changes to a gzipped file?

Regards,

Ken
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor

Re: sed gzipped files

Hi Ken:

How about a restore from backup...

Regards!

...JRF...
harry d brown jr
Honored Contributor

Re: sed gzipped files

If all they did was

sed "s/$/6|/" filename.gz

then the output was sent to the terminal and not to a file.

Was it something else they did??


live free or die
harry
Live Free or Die
Ken Tiernan
New Member

Re: sed gzipped files

I wish these people would follow the back it up before you screw it up rule, but...

Anyway, they ran a script that had a line like this:

sed "s/$/6|/" ${file} > ${file}.new
mv ${file}.new ${file}

or this:

sed "s/366|6|$/6|/" ${file} > ${file}.new
mv ${file}.new ${file}

The files that were altered were already gzipped, so the sed command corrupted the files, but I am hoping there is a way to reverse what was done.

A. Clay Stephenson
Acclaimed Contributor

Re: sed gzipped files

Unfortunately, there is no way to reliably reverse this process because one can't be assurred that the replacement pattern was not already in the original data. Moreover, running sed on non-text data is fraught with peril. It's time to restore from backup and break out the baseball bat - not necessarily in that order.
If it ain't broke, I can fix that.
harry d brown jr
Honored Contributor

Re: sed gzipped files

Ken,

I agree with JRF and CLAY, the files are TOAST. I ran the test myself and found that the "sed' removed the null strings from the file, rendering the files useless and unrecoverable. Unrecoverable, unless you are the nsa or CIA :-)

Get a Lawyer, get a company!

I'd persuade them that they owe you some SYSTEM upgrades, free software, new car, boat, hot tub, ... whatever your heart desires :-)


live free or die
harry
Live Free or Die
Wodisch_1
Honored Contributor

Re: sed gzipped files

Hi Ken,

well, assuming that those files are IMPORTANT, and that you have endless resources at hand (like time, and diskspace), you could write a script which would - for each and every file - re-substitute one "6|" at line ends after another, then run "gzip -t" on it, to check wether it is consistent, then. Of course you will have to do that for all COMBINATIONS af resubstitutions and not-substitutions, so it will take endless hours...
And "sed" might have deleted" some characters in addition, like zero-bytes - then you are truely lost :-(

But before you do antyhing, get proof that you are NOT the guilty guy! Make them confess on paper, safe and print their ".*history" files or such...

Paranoids live longer,
Wodisch