Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from May 1 '12 at 22:30

This question came from our site for professional and enthusiast programmers.

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

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

share|improve this answer

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.

share|improve this answer
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 May 5 '12 at 3:40
@up: my experience is that most distros do NOT alias these by default. – m_gol Oct 21 '12 at 12:19

You must log in to answer this question.

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