Re: undo rm -rf *

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxx> wrote:
      On Tue, Mar 26, 2013 at 22:23:29 +1100,
        Celik <celik.n.00@xxxxxxxxx> 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

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
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
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux