-2

I have one big problem. I had two files - main.c and logic.c. I have used sed for some modification in logic.c and then i saved it to main_updated.c and then run

mv main_updated.c main.c

BUT it had to be logic_updated.c and logic.c. PLS can anyone hlp me, how restore main.c file or i am dead.

5
  • This question is not a programming question; it is more suitable for either Super User or maybe Unix & Linux.
    – Jacques Cousteau
    Commented May 1, 2012 at 22:28
  • I don't suppose you were using a version control system...?
    – FatalError
    Commented May 1, 2012 at 22:28
  • sorry, move it pleas if someone can
    – Krab
    Commented May 1, 2012 at 22:29
  • Fatal: I do one commit to git, but that was in halb of my work on main.c :(
    – Krab
    Commented May 1, 2012 at 22:32
  • OS X is not Linux. Commented May 1, 2012 at 22:56

2 Answers 2

2

Chances are very likely that your old data is gone. It really depends on how the filesystem works when it comes to overwriting data - if the filesystem simply releases the inodes and allocates new ones elsewhere on the drive, you may be able to use a recovery program to find the data... maybe - you'd have to know where to look since it would probably return a bunch of inodes (and it may not know which ones contained all the data for your files, so you'd have to piece it together manually).

Lesson learned - commit after (most) every change ;P

0

I am afraid that you have in fact clobbered your main.c file.

In the future you can use mv "interactively" with:

mv -i filename new_filename/or_path

It will check with you before overwriting a file.

Also frequent commits with your version control software is a good idea.

2
  • Most distros seem to have aliases confgured for shells, such as alias mv mv -i to have a call to mv automatically include interactive mode.
    – Eli Sand
    Commented May 5, 2012 at 3:40
  • @up: my experience is that most distros do NOT alias these by default.
    – mgol
    Commented Oct 21, 2012 at 12:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .