big problem with rm command, please help me!!

Hi every body,

well, i made quite a big mistake... In a script, I created a directory called "$PWD" ( it was unwanted...). nothing very frightening with that. The problem is that I wanted to remove it and I used the command

rm -f -r $PWD

And here is the big mistake!! Rather than deleting the directory "$PWD" and all its contents, it removed all what was in current directory :eek:!

So here is my question: does anyone knows how to get back the data deleted with rm command??

Please, help me :frowning:

  1. Restore from snapshot
  2. Restore from backup

You can get back the data with a good and recent backup.

And congratulations: you've just learned 3 of the most valuable lessons:

  • Think twice before using rm -r, and double so when you are root
  • Always quote potential shell characters, except when you explicitly need them substituted
  • Always keep a good and current backup, and run test to ensure that you really can restore from it

Most of the filesystems - use restore. Some filesystems only remove file inode, but data is still on disk. In this case dd /dev/hardisk tosomefile and then try to get your data from file.

If somebody like to test real nice rm -r, here it is:

rm -fr .* 

It looks: remove all files which start with dot. Yes and directory also. Yes: . and .. belongs to .* ...

before use rm -r ... try the best debug command in shells: echo

echo rm -rf $PWD

You see what will shell do, if you remove echo ...

Tip:

Test whether you have correctly quoted the filename with "ls".
ls -lad \$PWD

Rename the awkward file
mv \$PWD myjunk

Then delete it using interractive delete for safety.
rm -i myjunk

By the way "rm -r *." should not delete ".." . See "man rm" where the specific command is explained.

Thx for your answers. I found another solution : contacting my computing office ^^. Files restored!