big problem with rm command, please help me!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting big problem with rm command, please help me!!
# 1  
Old 08-04-2009
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

Code:
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 Smilie!

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

Please, help me Smilie
# 2  
Old 08-04-2009
Quote:
Originally Posted by Moumou
So here is my question: does anyone knows how to get back the data deleted with rm command??
  1. Restore from snapshot
  2. Restore from backup
# 3  
Old 08-04-2009
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
# 4  
Old 08-04-2009
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:
Code:
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
Code:
echo rm -rf $PWD

You see what will shell do, if you remove echo ...
# 5  
Old 08-04-2009
Tip:
Code:
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.

Last edited by methyl; 08-04-2009 at 11:02 AM.. Reason: Addenda
# 6  
Old 08-04-2009
Thx for your answers. I found another solution : contacting my computing office ^^. Files restored!
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Big problem during the access for the password

Every time that i quit from the forum despite i'm 100 % sure that i put the right login (i make a copy and past of the correct data) i obtain always the message that the login is wrong so i must always reset it. :wall: Could be a bug? I use a 64 bit linux system. (4 Replies)
Discussion started by: alexscript
4 Replies

2. Shell Programming and Scripting

[newb] simple script, big problem

Warning! I'm ridiculously new at all this, so pardon my ignorance... I have a very simple script which is intended to search a hosts file when given a partial hostanme or ip address. The if the partial hostname/ip given is unique, the script automatically logs the user in to that host. If... (6 Replies)
Discussion started by: itomb
6 Replies

3. Programming

please help me with this big makefile problem

I need to create an executable with these two makefiles(they both have libaries i need(qt and ruby)) i have extconf.rb gui.ui gui_include.h main.cpp ScaleIM_client.rb ui_gui.h i want to combine them all into one executable please!... (2 Replies)
Discussion started by: gjgfuj
2 Replies

4. Linux

Problem with creating big files

Hi... I have a very wired problem with my redhat4 update 4 server... Every time i create a file bigger then my physical memory the server kills the process\session that creates the file, and in the "messages" file i see this error: "Oct 21 15:22:22 optidev kernel: Out of Memory: Killed process... (6 Replies)
Discussion started by: eliraza6
6 Replies

5. UNIX for Dummies Questions & Answers

A Big Problem in LINUX Booting

i have some problem in linux booting will u please help me the problem is i was using federo core 1 on my system everything was fine i made one entry in /etc/fstab file for accessing E drive of WINDOWS XP in that i had given file system as VFAT after rebooting system it was not... (1 Reply)
Discussion started by: great_indian
1 Replies

6. UNIX for Dummies Questions & Answers

kinda big problem

Hi again! I finally managed to image the 3 floppies for installing freeBSD but I simply can't boot! I've selected floppy for first boot device and it even starts to readf the boot floppy and the hard drive light is continuously flashing but it doesn't stop even after half an hour and doesn't do a... (4 Replies)
Discussion started by: Mudrack
4 Replies

7. UNIX for Advanced & Expert Users

a BIG problem

dear experts ...help :eek: I'm running FC2 and i was installing fluxbox but it wouldnt work so i uninstalled it by using rpm -e but because i installed fluxbox-styles it was dependent on fluxbox-0.10 so i used rpm -e --nodeps that was all fine and im not sure that was the cause of the error, but... (1 Reply)
Discussion started by: zeeman
1 Replies

8. UNIX for Dummies Questions & Answers

problem editing big file in vi

I have a big file, which vi opens it with message not sufficient space with file system. I am not adding any data in the file but changing some values within. To make these changes effective, it asks for forced write (w!), even after doing this, I see this particular record, change is not... (4 Replies)
Discussion started by: videsh77
4 Replies
Login or Register to Ask a Question