Re: undo rm -rf *

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

 



Celik wrote:


On Tue, Mar 26, 2013 at 11:57 PM, jarmo <oh1mrr@xxxxxx <mailto:oh1mrr@xxxxxx>>
wrote:

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

--
Bill Davidsen <davidsen@xxxxxxx>
  "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot
--
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