Hi,
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?
Regards, C
Am 26.03.2013 12:23, schrieb Celik:
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?
no way on a modern system which permanently writes to the disk and the journal, in other words this is the hard way to learn about backups
ohhh dear...:(
thanks for the quick reply.
On Tue, Mar 26, 2013 at 10:27 PM, Reindl Harald h.reindl@thelounge.netwrote:
Am 26.03.2013 12:23, schrieb Celik:
Had a logic error in my bash script and did "rm -rf *" on my current
working directory. Any tips for undoing such
an error?
no way on a modern system which permanently writes to the disk and the journal, in other words this is the hard way to learn about backups
-- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
There are a number of utilities that will attempt this for you. Google "undelete ext4 linux" assuming your filesystem is ext4.
However, as your system is used the now unallocated space is being re-used reducing any your chances of success. Even installing an uninstall utility will do this, as would switching to single user or shutting down.
Even if you do nothing, the services in the background will be updating the filestore,
On Tuesday 26 March 2013 11:23:29 Celik wrote:
Hi,
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?
Regards, C
On Tue, Mar 26, 2013 at 10:37 PM, Gary Stainburn < gary.stainburn@ringways.co.uk> wrote:
There are a number of utilities that will attempt this for you. Google "undelete ext4 linux" assuming your filesystem is ext4.
Gary, thank you for the information. Installed testdisk and exundelete. In the process most likely substantially decreased any chance of recovering the files. Tried exundelete but couldn't get it to work. Will figure out how to use the programs just in case needed in the future.
Meanwhile, lost only few hours of work.
Anyhow, thanks for the support.
However, as your system is used the now unallocated space is being re-used reducing any your chances of success. Even installing an uninstall utility will do this, as would switching to single user or shutting down.
Even if you do nothing, the services in the background will be updating the filestore,
On Tuesday 26 March 2013 11:23:29 Celik wrote:
Hi,
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?
Regards, C
-- Gary Stainburn Group I.T. Manager Ringways Garages http://www.ringways.co.uk -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
The last time this happened to me, I had some luck using sleuthkit:
As you noted, installing new things on your computer is destructive to deleted files. It's a good idea, if you can, to make an image of your disk asap and then work on that image. What I have done is put a live distro on a flash drive, boot from the live distro, dd the native disk to an external drive, and then run the recovery utils on the image.
billo
On Wed, 27 Mar 2013, Celik wrote:
On Tue, Mar 26, 2013 at 10:37 PM, Gary Stainburn gary.stainburn@ringways.co.uk wrote: There are a number of utilities that will attempt this for you. Google "undelete ext4 linux" assuming your filesystem is ext4.
Gary, thank you for the information. Installed testdisk and exundelete. In the process most likely substantially decreased any chance of recovering the files. Tried exundelete but couldn't get it to work. Will figure out how to use the programs just in case needed in the future.
Meanwhile, lost only few hours of work.
Anyhow, thanks for the support.
However, as your system is used the now unallocated space is being re-used reducing any your chances of success. Even installing an uninstall utility will do this, as would switching to single user or shutting down.
Even if you do nothing, the services in the background will be updating the filestore, On Tuesday 26 March 2013 11:23:29 Celik wrote: > Hi, > > Had a logic error in my bash script and did "rm -rf *" on my current > working directory. Any tips for undoing such an error? > > Regards, > C-- Gary Stainburn Group I.T. Manager Ringways Garages http://www.ringways.co.uk -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
On Wed, Mar 27, 2013 at 1:49 AM, Bill Oliver vendor@billoblog.com wrote:
The last time this happened to me, I had some luck using sleuthkit:
As you noted, installing new things on your computer is destructive to deleted files. It's a good idea, if you can, to make an image of your disk asap and then work on that image. What I have done is put a live distro on a flash drive, boot from the live distro, dd the native disk to an external drive, and then run the recovery utils on the image.
billo
Bill, re-did the work. Because it was fresh in my mind, it didn't take as long.
The tasks you have mentioned (i.e. making an image of disk and dd) are new to me. I'll try to follow the steps with some dummy files on my laptop. The laptop is for testing new programs if anything goes wrong won't cause much heart-ache.
Please excuse me if this going to be a silly question, so can we use dd for making backups of our files/computer? or can we make an image of our disk solely for a backup purpose?
On Wed, 27 Mar 2013, Celik wrote:
On Tue, Mar 26, 2013 at 10:37 PM, Gary Stainburn < gary.stainburn@ringways.co.uk**> wrote: There are a number of utilities that will attempt this for you. Google "undelete ext4 linux" assuming your filesystem is ext4.
Gary, thank you for the information. Installed testdisk and exundelete. In the process most likely substantially decreased any chance of recovering the files. Tried exundelete but couldn't get it to work. Will figure out how to use the programs just in case needed in the future.
Meanwhile, lost only few hours of work.
Anyhow, thanks for the support.
However, as your system is used the now unallocated space is beingre-used reducing any your chances of success. Even installing an uninstall utility will do this, as would switching to single user or shutting down.
Even if you do nothing, the services in the background will beupdating the filestore,
On Tuesday 26 March 2013 11:23:29 Celik wrote: > Hi, > > Had a logic error in my bash script and did "rm -rf *" on mycurrent > working directory. Any tips for undoing such an error? > > Regards, > C
-- Gary Stainburn Group I.T. Manager Ringways Garages http://www.ringways.co.uk -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.**org/mailman/listinfo/usershttps://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/**Mailing_list_guidelineshttp://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
-- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
The "dd" command is a workhorse, sorta like netcat. The answer to "can you use if for copying/backing up XXX" is essentially always "yes." However, it's not convenient for some things. For instance, it copies *files.* Even though the old unix cant is that "everything is a file," it turns out that you sometimes have to play around for file-oriented utilities to play well with directories -- I don't think there's a recursive option for dd.
I don't use dd for backups where I don't want a disk or partition image because I don't want to backup everything, I don't want bit-for-bit backups of individual files (as I remember, dd will back up slack space as well as the file itself), and other tools are more friendly. Rsync is my friend. As with most things in linux, there are 15 ways to do anything, and which is "best" depends on the circumstances, taste, and effort. Sometimes it's easier to use a slightly less efficient tool you know well than a more efficient one you don't.
However, dd gurus often find a way for using it for everything, it seems. Here's a nice review:
http://www.thegeekstuff.com/2010/10/dd-command-examples/
and
http://endlessparadigm.com/forum/showthread.php?tid=8016
billo
On Wed, 27 Mar 2013, Celik wrote:
On Wed, Mar 27, 2013 at 1:49 AM, Bill Oliver vendor@billoblog.com wrote:
The last time this happened to me, I had some luck using sleuthkit: http://www.sleuthkit.org/ As you noted, installing new things on your computer is destructive to deleted files. It's a good idea, if you can, to make an image of your disk asap and then work on that image. What I have done is put a live distro on a flash drive, boot from the live distro, dd the native disk to an external drive, and then run the recovery utils on the image. billoBill, re-did the work. Because it was fresh in my mind, it didn't take as long.
The tasks you have mentioned (i.e. making an image of disk and dd) are new to me. I'll try to follow the steps with some dummy files on my laptop. The laptop is for testing new programs if anything goes wrong won't cause much heart-ache.
Please excuse me if this going to be a silly question, so can we use dd for making backups of our files/computer? or can we make an image of our disk solely for a backup purpose?
On Wed, 27 Mar 2013, Celik wrote: On Tue, Mar 26, 2013 at 10:37 PM, Gary Stainburn <gary.stainburn@ringways.co.uk> wrote: There are a number of utilities that will attempt this for you. Google "undelete ext4 linux" assuming your filesystem is ext4. Gary, thank you for the information. Installed testdisk and exundelete. In the process most likely substantially decreased any chance of recovering the files. Tried exundelete but couldn't get it to work. Will figure out how to use the programs just in case needed in the future. Meanwhile, lost only few hours of work. Anyhow, thanks for the support. However, as your system is used the now unallocated space is being re-used reducing any your chances of success. Even installing an uninstall utility will do this, as would switching to single user or shutting down. Even if you do nothing, the services in the background will be updating the filestore, On Tuesday 26 March 2013 11:23:29 Celik wrote: > Hi, > > Had a logic error in my bash script and did "rm -rf *" on my current > working directory. Any tips for undoing such an error? > > Regards, > C -- Gary Stainburn Group I.T. Manager Ringways Garages http://www.ringways.co.uk -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org-- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Celik wrote:
On Wed, Mar 27, 2013 at 1:49 AM, Bill Oliver <vendor@billoblog.com mailto:vendor@billoblog.com> wrote:
The last time this happened to me, I had some luck using sleuthkit: http://www.sleuthkit.org/ As you noted, installing new things on your computer is destructive to deleted files. It's a good idea, if you can, to make an image of your disk asap and then work on that image. What I have done is put a live distro on a flash drive, boot from the live distro, dd the native disk to an external drive, and then run the recovery utils on the image. billoBill, re-did the work. Because it was fresh in my mind, it didn't take as long.
The tasks you have mentioned (i.e. making an image of disk and dd) are new to me. I'll try to follow the steps with some dummy files on my laptop. The laptop is for testing new programs if anything goes wrong won't cause much heart-ache.
Please excuse me if this going to be a silly question, so can we use dd for making backups of our files/computer? or can we make an image of our disk solely for a backup purpose?
You can use dd to make a bit for bit backup of your drive to an identical (or larger) drive. That is useful, but quite time consuming. To back up the files you can use tar in more cases, assuming you are not doing anything truly bizarre with extended attributes, access control lists, (shudder) using hard links to directories. A normal filesystem backs up far faster and smaller using a tool like tar or one of the specialized packages.
For keeping a full backup I highly recommend looking at rsync, which can keep your files backed up in a very efficient manner.
Note that if you choose "cloud backup" from one of the vendors, on many network connections the upload speed is far slower than the download speed, and you spend a lot of time backing up. Mentioned because people forget until they try to do something large and it takes forever.
Tue, 26 Mar 2013 22:23:29 +1100 Celik celik.n.00@gmail.com kirjoitti:
Hi,
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?
Regards, C
Just try to find your BACKUP :))
On Tue, Mar 26, 2013 at 11:57 PM, jarmo oh1mrr@nic.fi wrote:
Tue, 26 Mar 2013 22:23:29 +1100 Celik celik.n.00@gmail.com kirjoitti:
Hi,
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?
Regards, C
Just try to find your BACKUP :))
Very funny :))) Didn't have a backup... :))) ohh dear laughing at lost work...:))) Seems like I need pickup new skills on making "proper/better" backups
Thanks for making me laugh...much appreciated :)))
-- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Celik wrote:
On Tue, Mar 26, 2013 at 11:57 PM, jarmo <oh1mrr@nic.fi mailto:oh1mrr@nic.fi> wrote:
Tue, 26 Mar 2013 22:23:29 +1100 Celik <celik.n.00@gmail.com <mailto:celik.n.00@gmail.com>> kirjoitti: > Hi, > > Had a logic error in my bash script and did "rm -rf *" on my current > working directory. Any tips for undoing such an error? > > Regards, > C Just try to find your BACKUP :))Very funny :))) Didn't have a backup... :))) ohh dear laughing at lost work...:))) Seems like I need pickup new skills on making "proper/better" backups
Thanks for making me laugh...much appreciated :)))
Actually better skills at scripting might be job one, use of "rm -rf" is ALWAYS dangerous, I suggest putting temporary stuff in a subdir using the process id, and deleting that at the end. If you miss you don't delete anything. MyWk=joe-$$-$RANDOM mkdir ${MyWk} || exit 2 # do stuff rm -rf ${MyWk}
I would qualify that as "less unsafe" rather than idiot proof, but using both the process id and a random number does avoid reusing a name. Note that if the mkdir fails the script bails out immediately. Belt and suspenders programming.
On Tue, Mar 26, 2013 at 22:23:29 +1100, Celik celik.n.00@gmail.com wrote:
Hi,
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?
I've done worse. I once did rm -rf .* to try to remove some config files in a home directory. I forgot that .* matched .. and deleted a lot of stuff I didn't want to.
On Wed, Mar 27, 2013 at 1:14 AM, Bruno Wolff III bruno@wolff.to wrote:
On Tue, Mar 26, 2013 at 22:23:29 +1100, Celik celik.n.00@gmail.com wrote:
Hi,
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?
I've done worse. I once did rm -rf .* to try to remove some config files in a home directory. I forgot that .* matched .. and deleted a lot of stuff I didn't want to.
Bruno, after such an experience, did you come up with an alternative solution to using "rm -rf"? "rm -i" is good as it prompts before deletion however it becomes tedious if there are a lot of files to be deleted, hence "rm -rf" seems ideal but dangerous if not cautious :( Had a look on google, there was one particular recommendation that caught me attention (sorry I don't have the link). It was recommended to mv the files (and/or folders) to be deleted into a tmp directory. I'm planning to try that in my future code, we'll see how things go.
Regards, C
On Wed, Mar 27, 2013 at 03:11:54 +1100, Celik celik.n.00@gmail.com wrote:
Bruno, after such an experience, did you come up with an alternative solution to using "rm -rf"? "rm -i" is good as it prompts before deletion however it becomes tedious if there are a lot of files to be deleted, hence "rm -rf" seems ideal but dangerous if not cautious :( Had a look on google, there was one particular recommendation that caught me attention (sorry I don't have the link). It was recommended to mv the files (and/or folders) to be deleted into a tmp directory. I'm planning to try that in my future code, we'll see how things go.
Try to be more careful, especially when there is an asterisk involved. And I keep in mind about '..', so no deleting '.*'.
Am 26.03.2013 17:16, schrieb Bruno Wolff III:
On Wed, Mar 27, 2013 at 03:11:54 +1100, Celik celik.n.00@gmail.com wrote:
Bruno, after such an experience, did you come up with an alternative solution to using "rm -rf"? "rm -i" is good as it prompts before deletion however it becomes tedious if there are a lot of files to be deleted, hence "rm -rf" seems ideal but dangerous if not cautious :( Had a look on google, there was one particular recommendation that caught me attention (sorry I don't have the link). It was recommended to mv the files (and/or folders) to be deleted into a tmp directory. I'm planning to try that in my future code, we'll see how things go.
Try to be more careful, especially when there is an asterisk involved. And I keep in mind about '..', so no deleting '.*'
and how yoill you remove all hidden files of a folder? this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
On Tue, Mar 26, 2013 at 17:21:28 +0100, Reindl Harald h.reindl@thelounge.net wrote:
and how yoill you remove all hidden files of a folder?
For cases where I just want dot files/dirs removed I use '.??*'. That only hits names at least three characters long.
this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
That's an improvement. I hadn't tested doing an rm -rf of .. for about 10 years. That version of rm starting decsending .. before doing any check for whether .. should be removed.
On Tue, 2013-03-26 at 17:21 +0100, Reindl Harald wrote:
Am 26.03.2013 17:16, schrieb Bruno Wolff III:
On Wed, Mar 27, 2013 at 03:11:54 +1100, Celik celik.n.00@gmail.com wrote:
Bruno, after such an experience, did you come up with an alternative solution to using "rm -rf"? "rm -i" is good as it prompts before deletion however it becomes tedious if there are a lot of files to be deleted, hence "rm -rf" seems ideal but dangerous if not cautious :( Had a look on google, there was one particular recommendation that caught me attention (sorry I don't have the link). It was recommended to mv the files (and/or folders) to be deleted into a tmp directory. I'm planning to try that in my future code, we'll see how things go.
Try to be more careful, especially when there is an asterisk involved. And I keep in mind about '..', so no deleting '.*'
and how yoill you remove all hidden files of a folder?
rm -rf .??*
This would miss files with only one character after the dot in the name, like .a, but those can be handled explicitly with less trouble than recovering from mistakenly deleting the contents of the parent directory.
this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
Does this not depend on where in the tree you are and what permissions you have on . and ..?
Am 26.03.2013 18:03, schrieb Matthew Saltzman:
this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
Does this not depend on where in the tree you are and what permissions you have on . and ..?
how many more permissions will you have than root?
On 03/26/2013 10:35 AM, Reindl Harald issued this missive:
Am 26.03.2013 18:03, schrieb Matthew Saltzman:
this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
Does this not depend on where in the tree you are and what permissions you have on . and ..?
how many more permissions will you have than root?
"rm" and "rmdir" take care to not delete "." or "..". "rm" also requires the "-f" along with "-r" to delete non-empty directories. You don't want to delete your current directory (".") and you sure don't want to delete its parent (".."). Doing either orphans the shell you're in (it has no current directory). Yes, you can delete them from another shell and orphan the current one, but that's bad practice.
Unless you're ABSOLUTELY certain you are deleting what you want, you should check the results of an "ls" and possibly use the "-i", "-I" or "--interactive" flags. ---------------------------------------------------------------------- - Rick Stevens, Systems Engineer, AllDigital ricks@alldigital.com - - AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 - - - - Give me ambiguity or give me something else! - ----------------------------------------------------------------------
Am 26.03.2013 21:08, schrieb Rick Stevens:
On 03/26/2013 10:35 AM, Reindl Harald issued this missive:
Am 26.03.2013 18:03, schrieb Matthew Saltzman:
this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
Does this not depend on where in the tree you are and what permissions you have on . and ..?
how many more permissions will you have than root?
"rm" and "rmdir" take care to not delete "." or "..". "rm" also requires the "-f" along with "-r" to delete non-empty directories. You don't want to delete your current directory (".") and you sure don't want to delete its parent ("..")
and you don't as proven above
Reindl Harald wrote:
Am 26.03.2013 21:08, schrieb Rick Stevens:
On 03/26/2013 10:35 AM, Reindl Harald issued this missive:
Am 26.03.2013 18:03, schrieb Matthew Saltzman:
this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
Does this not depend on where in the tree you are and what permissions you have on . and ..?
how many more permissions will you have than root?
"rm" and "rmdir" take care to not delete "." or "..". "rm" also requires the "-f" along with "-r" to delete non-empty directories. You don't want to delete your current directory (".") and you sure don't want to delete its parent ("..")
and you don't as proven above
I hate to say it, but I don't want to ever have to trust that the rm I'm getting is the one I expect and not some alias, function, thing earlier on a PATH, and that I'm on a recent system which protects me from being reckless. If I have to think that hard I'd rather just use something safer and not put my faith in a check which I know is not universal to all systems.
I am not a trusting person.
Am 30.03.2013 04:18, schrieb Bill Davidsen:
Reindl Harald wrote:
Am 26.03.2013 21:08, schrieb Rick Stevens:
On 03/26/2013 10:35 AM, Reindl Harald issued this missive:
Am 26.03.2013 18:03, schrieb Matthew Saltzman:
this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
Does this not depend on where in the tree you are and what permissions you have on . and ..?
how many more permissions will you have than root?
"rm" and "rmdir" take care to not delete "." or "..". "rm" also requires the "-f" along with "-r" to delete non-empty directories. You don't want to delete your current directory (".") and you sure don't want to delete its parent ("..")
and you don't as proven above
I hate to say it, but I don't want to ever have to trust that the rm I'm getting is the one I expect and not some alias, function, thing earlier on a PATH,
i hate to say it, but i know how to do my job and control aliases and PATH _______________________________________
[harry@srv-rhsoft:~]$ cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/harry/bin:/scripts unset USERNAME _______________________________________
[harry@srv-rhsoft:~]$ cat .bashrc # .bashrc PS1="[\033[1;32m][\u@\h:\w]$[\033[0m] " # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi if [ -f /usr/local/etc/bash_profile ]; then . /usr/local/etc/bash_profile fi export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/harry/bin:/scripts _______________________________________
[harry@srv-rhsoft:~]$ cat /usr/local/etc/bash_profile | grep rm alias rm='/usr/bin/rm -I --one-file-system'
Reindl Harald wrote:
Am 26.03.2013 17:16, schrieb Bruno Wolff III:
On Wed, Mar 27, 2013 at 03:11:54 +1100, Celik celik.n.00@gmail.com wrote:
Bruno, after such an experience, did you come up with an alternative solution to using "rm -rf"? "rm -i" is good as it prompts before deletion however it becomes tedious if there are a lot of files to be deleted, hence "rm -rf" seems ideal but dangerous if not cautious :( Had a look on google, there was one particular recommendation that caught me attention (sorry I don't have the link). It was recommended to mv the files (and/or folders) to be deleted into a tmp directory. I'm planning to try that in my future code, we'll see how things go.
Try to be more careful, especially when there is an asterisk involved. And I keep in mind about '..', so no deleting '.*'
and how yoill you remove all hidden files of a folder? this is safe since a very long time
[root@testserver:/tmp]$ LANG=c; /usr/bin/rm -rf .* /usr/bin/rm: cannot remove directory: '.' /usr/bin/rm: cannot remove directory: '..'
For ease of typing usually: rm .[a-z]* will do, or if paranoid: find . -maxdepth 1 -type f -iname .* -exec rm "{}" ; which avoids directories because you (usually) didn't mean that.
I'm not a fan of trash directories. They give you a second chance, but you may end up not really deleting things you wanted to delete. What about a simple script something like this? This is off the top of my head and not tested (so certainly has a bug or two), but it seems that you could check with something like this:
#!/bin/sh
echo "check?"
read ANS
if [ $ANS = "y" ]
then
ls -laR $1 | more
echo "continue?"
read ANS2
if [ $ANS2 = "y" ]
then
rm -fr $1
fi else
rm -fr $1
fi
Of course there are two problems with big deletions. If you use more, it would get boring hitting the space bar a zillion times, and if you don't, then you won't see the files...
billo
On Wed, 27 Mar 2013, Celik wrote:
On Wed, Mar 27, 2013 at 1:14 AM, Bruno Wolff III bruno@wolff.to wrote: On Tue, Mar 26, 2013 at 22:23:29 +1100, Celik celik.n.00@gmail.com wrote: Hi,
Had a logic error in my bash script and did "rm -rf *" on my current working directory. Any tips for undoing such an error?I've done worse. I once did rm -rf .* to try to remove some config files in a home directory. I forgot that .* matched .. and deleted a lot of stuff I didn't want to.
Bruno, after such an experience, did you come up with an alternative solution to using "rm -rf"? "rm -i" is good as it prompts before deletion however it becomes tedious if there are a lot of files to be deleted, hence "rm -rf" seems ideal but dangerous if not cautious :( Had a look on google, there was one particular recommendation that caught me attention (sorry I don't have the link). It was recommended to mv the files (and/or folders) to be deleted into a tmp directory. I'm planning to try that in my future code, we'll see how things go.
Regards, C
guys...
as a face saving process... always test what ever you're going to do when using RM <<< and then substitute ls for rm to see what the results would be...
and finally, before you do a "rm" .. make sure you have a complete backup that you can restore from, in the event you really do trash something up!
jus' sayin!
On Tue, Mar 26, 2013 at 1:38 PM, Bill Oliver vendor@billoblog.com wrote:
I'm not a fan of trash directories. They give you a second chance, but you may end up not really deleting things you wanted to delete. What about a simple script something like this? This is off the top of my head and not tested (so certainly has a bug or two), but it seems that you could check with something like this:
#!/bin/sh
echo "check?"
read ANS
if [ $ANS = "y" ]
then
ls -laR $1 | more echo "continue?" read ANS2 if [ $ANS2 = "y" ] then rm -fr $1 fielse
rm -fr $1fi
Of course there are two problems with big deletions. If you use more, it would get boring hitting the space bar a zillion times, and if you don't, then you won't see the files...
billo
On Wed, 27 Mar 2013, Celik wrote:
On Wed, Mar 27, 2013 at 1:14 AM, Bruno Wolff III bruno@wolff.to wrote: On Tue, Mar 26, 2013 at 22:23:29 +1100, Celik celik.n.00@gmail.com wrote: Hi,
Had a logic error in my bash script and did "rm -rf *" on mycurrent working directory. Any tips for undoing such an error?
I've done worse. I once did rm -rf .* to try to remove some config files in a home directory. I forgot that .* matched .. and deleted a lot of stuff I didn't want to.
Bruno, after such an experience, did you come up with an alternative solution to using "rm -rf"? "rm -i" is good as it prompts before deletion however it becomes tedious if there are a lot of files to be deleted, hence "rm -rf" seems ideal but dangerous if not cautious :( Had a look on google, there was one particular recommendation that caught me attention (sorry I don't have the link). It was recommended to mv the files (and/or folders) to be deleted into a tmp directory. I'm planning to try that in my future code, we'll see how things go.
Regards, C
-- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org
Allegedly, on or about 26 March 2013, bruce sent:
as a face saving process... always test what ever you're going to do when using RM <<< and then substitute ls for rm to see what the results would be...
I would, also, think carefully about whether you really do need the force flag. Some people just jam that in out of habit.
On 03/27/2013 11:28 AM, Tim wrote:
Allegedly, on or about 26 March 2013, bruce sent:
as a face saving process... always test what ever you're going to do when using RM <<< and then substitute ls for rm to see what the results would be...
I would, also, think carefully about whether you really do need the force flag. Some people just jam that in out of habit.
Reminded me of another dangerous habit some people get into - exiting 'vi/vim' with ':wq!' always.
On Wed, 2013-03-27 at 14:25 +0530, Rejy M Cyriac wrote:
Reminded me of another dangerous habit some people get into - exiting 'vi/vim' with ':wq!' always.
I've seen similar with the Word word-processor, some users would be asked to save changes to the document as they quit, and always click on yes, never thinking that they'd only been reading that particular document and hadn't purposely made any changes to it. If there were any changes, they were accidental (such as leaning on the keys, or some other user error in operation), and quite likely to have lost something significant by saving a modified document.
When doing things with computers, you really need to pay attention and think about what you're doing, it's very easy to make big mistakes that you can't undo.
On Wed, Mar 27, 2013 at 4:38 AM, Bill Oliver vendor@billoblog.com wrote:
I'm not a fan of trash directories. They give you a second chance, but you may end up not really deleting things you wanted to delete. What about a simple script something like this? This is off the top of my head and not tested (so certainly has a bug or two), but it seems that you could check with something like this:
#!/bin/sh
echo "check?"
read ANS
if [ $ANS = "y" ]
then
ls -laR $1 | more echo "continue?" read ANS2 if [ $ANS2 = "y" ] then rm -fr $1 fielse
rm -fr $1fi
Yes that script will do to prevent accidental deletions in the future. Modified it slightly and posting it just in case needed by someone else. Thank you :)
#!/bin/bash
echo -e "prompt-bf-deletion.sh...\n"
rm_target=$1
echo "+++Content(s) to be deleted:" ls -laR $rm_target | more
echo -e "\n+++Continue with deletion (y/n)?"
read ANS
if [ $ANS = "y" ]; then rm -fr $rm_target echo -e "Contents deleted...\n" else echo -e "Exiting without deletion...\n"
fi
exit
Of course there are two problems with big deletions. If you use more, it would get boring hitting the space bar a zillion times, and if you don't, then you won't see the files...
billo
On Wed, 27 Mar 2013, Celik wrote:
On Wed, Mar 27, 2013 at 1:14 AM, Bruno Wolff III bruno@wolff.to wrote: On Tue, Mar 26, 2013 at 22:23:29 +1100, Celik celik.n.00@gmail.com wrote: Hi,
Had a logic error in my bash script and did "rm -rf *" on mycurrent working directory. Any tips for undoing such an error?
I've done worse. I once did rm -rf .* to try to remove some config files in a home directory. I forgot that .* matched .. and deleted a lot of stuff I didn't want to.
Bruno, after such an experience, did you come up with an alternative solution to using "rm -rf"? "rm -i" is good as it prompts before deletion however it becomes tedious if there are a lot of files to be deleted, hence "rm -rf" seems ideal but dangerous if not cautious :( Had a look on google, there was one particular recommendation that caught me attention (sorry I don't have the link). It was recommended to mv the files (and/or folders) to be deleted into a tmp directory. I'm planning to try that in my future code, we'll see how things go.
Regards, C