Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Creating a -i file to protect a directory
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
kapheine
n00b
n00b


Joined: 01 Aug 2002
Posts: 31
Location: Rochester, NY

PostPosted: Fri Aug 02, 2002 4:51 pm    Post subject: Creating a -i file to protect a directory Reply with quote

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
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Fri Aug 02, 2002 5:02 pm    Post subject: Reply with quote

Wouldn't it be easier to alias rm to do an rm -i?
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
abhishek
Retired Dev
Retired Dev


Joined: 28 Jun 2002
Posts: 393
Location: Los Angeles, CA

PostPosted: Fri Aug 02, 2002 6:58 pm    Post subject: Reply with quote

How would u delete the file?
Back to top
View user's profile Send private message
xming
Guru
Guru


Joined: 02 Jul 2002
Posts: 441

PostPosted: Fri Aug 02, 2002 7:51 pm    Post subject: rm Reply with quote

like how you created it

rm /path/-i

or

cd /path
rm ./-i
Back to top
View user's profile Send private message
abhishek
Retired Dev
Retired Dev


Joined: 28 Jun 2002
Posts: 393
Location: Los Angeles, CA

PostPosted: Fri Aug 02, 2002 7:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
kapheine
n00b
n00b


Joined: 01 Aug 2002
Posts: 31
Location: Rochester, NY

PostPosted: Fri Aug 02, 2002 11:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
radfaraf
n00b
n00b


Joined: 25 May 2002
Posts: 55
Location: NJ

PostPosted: Sat Aug 03, 2002 10:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum