Server Fault is a question and answer site for system and network administrators. 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

how to recover a .c file in AIX unix which has removed (rm -f) by accidentally

share|improve this question

migrated from Feb 4 '10 at 14:25

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

Just grab it from your daily/weekly backups

You have backups right?

Coincidentally, there is an FAQ at FAQS for this. Follow directions at your own peril...

share|improve this answer
Deleted file has not checked in CVS server yet. It's newly created file. – Thi Feb 4 '10 at 13:46

If your FS is not journal-enabled and you remember any "unique" string in the content of the file you can use as a search seed a simple way is to:

  • mount the partition ro (or unmount it, if it is possible) in order to avoid accidental overwrite of the sectors involved
  • grep the partition device for the string you really know the deleted file has to contain

Of course you have to adjust -B and -A grep options, in order to be able to retrieve the entire file (set the lines before and after the searching string you have to grep). Redirect grep output on a new file and adjust it to remove exceeding heading and trailing lines.

I used this method a number of times, with very good results.

grep -i -B 1000 -A 1000 \
      "your seed string you are really sure to find in the deleted file" \
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.