View previous topic :: View next topic |
Author |
Message |
kapheine n00b
Joined: 01 Aug 2002 Posts: 31 Location: Rochester, NY
|
Posted: Fri Aug 02, 2002 4:51 pm Post subject: Creating a -i file to protect a directory |
|
|
If you don't have rm aliased to rm -i to protect yourself from accidental deletions but want some extra protection on select directories, try the following:
Code: | $ touch -- /path/to/directory/-i |
Now, if you accidentally type rm -rf /directory or rm /directory/* by accident, -i will be passed to the shell and confirmation will be turned on. If later you decide to remove the file, try:
Code: | $ rm -- /path/to/directory/-i |
|
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Fri Aug 02, 2002 5:02 pm Post subject: |
|
|
Wouldn't it be easier to alias rm to do an rm -i? _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
abhishek Retired Dev
Joined: 28 Jun 2002 Posts: 393 Location: Los Angeles, CA
|
Posted: Fri Aug 02, 2002 6:58 pm Post subject: |
|
|
How would u delete the file? |
|
Back to top |
|
|
xming Guru
Joined: 02 Jul 2002 Posts: 441
|
Posted: Fri Aug 02, 2002 7:51 pm Post subject: rm |
|
|
like how you created it
rm /path/-i
or
cd /path
rm ./-i |
|
Back to top |
|
|
abhishek Retired Dev
Joined: 28 Jun 2002 Posts: 393 Location: Los Angeles, CA
|
Posted: Fri Aug 02, 2002 7:54 pm Post subject: |
|
|
Cool. If only i jad known that a while ago when some1 made some files in my home directory(-fu) and i had no idea how to delite them. Thanks. |
|
Back to top |
|
|
kapheine n00b
Joined: 01 Aug 2002 Posts: 31 Location: Rochester, NY
|
Posted: Fri Aug 02, 2002 11:42 pm Post subject: |
|
|
kanuslupus wrote: | Wouldn't it be easier to alias rm to do an rm -i? |
For most people, yeah. But some people are like me, and in general they don't like to have -i on. 99% of the time when I say I want to delete a file, I want it deleted. Once or twice, however, I've been an idiot and did an rm * in my home directory. After that, I started added extra protection just to my home directory. |
|
Back to top |
|
|
radfaraf n00b
Joined: 25 May 2002 Posts: 55 Location: NJ
|
Posted: Sat Aug 03, 2002 10:00 pm Post subject: |
|
|
mp3box kingfool # mkdir test
mp3box kingfool # touch test/-i
mp3box kingfool # rm -r test
lets me delete the file with no complaints |
|
Back to top |
|
|
|