Interactive rm command

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
When I remove some directories, I often forgot their structure and consequently I don't add the -rf flags when needed. When this happens, rm just returns an error and reminds me that I am trying to delete a directory.
Is there a program that would instead ask whether I want to remove the directory, or remove with root privileges?
rm foo
foo is directory, Want to remove it [Y/n]
foo/bar owned by root, Want to increase privileges [Y/n]
rm
add a comment |Â
up vote
0
down vote
favorite
When I remove some directories, I often forgot their structure and consequently I don't add the -rf flags when needed. When this happens, rm just returns an error and reminds me that I am trying to delete a directory.
Is there a program that would instead ask whether I want to remove the directory, or remove with root privileges?
rm foo
foo is directory, Want to remove it [Y/n]
foo/bar owned by root, Want to increase privileges [Y/n]
rm
It doesn't matter who ownsfoo/bar(as long asfoodoesn't have thetbit). To be able to delete it, you only need write access tofoo.
â Stéphane Chazelas
Oct 30 '17 at 10:29
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When I remove some directories, I often forgot their structure and consequently I don't add the -rf flags when needed. When this happens, rm just returns an error and reminds me that I am trying to delete a directory.
Is there a program that would instead ask whether I want to remove the directory, or remove with root privileges?
rm foo
foo is directory, Want to remove it [Y/n]
foo/bar owned by root, Want to increase privileges [Y/n]
rm
When I remove some directories, I often forgot their structure and consequently I don't add the -rf flags when needed. When this happens, rm just returns an error and reminds me that I am trying to delete a directory.
Is there a program that would instead ask whether I want to remove the directory, or remove with root privileges?
rm foo
foo is directory, Want to remove it [Y/n]
foo/bar owned by root, Want to increase privileges [Y/n]
rm
edited Oct 30 '17 at 10:08
kiamlaluno
362220
362220
asked Oct 30 '17 at 9:08
user1685095
282313
282313
It doesn't matter who ownsfoo/bar(as long asfoodoesn't have thetbit). To be able to delete it, you only need write access tofoo.
â Stéphane Chazelas
Oct 30 '17 at 10:29
add a comment |Â
It doesn't matter who ownsfoo/bar(as long asfoodoesn't have thetbit). To be able to delete it, you only need write access tofoo.
â Stéphane Chazelas
Oct 30 '17 at 10:29
It doesn't matter who owns
foo/bar (as long as foo doesn't have the t bit). To be able to delete it, you only need write access to foo.â Stéphane Chazelas
Oct 30 '17 at 10:29
It doesn't matter who owns
foo/bar (as long as foo doesn't have the t bit). To be able to delete it, you only need write access to foo.â Stéphane Chazelas
Oct 30 '17 at 10:29
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
No, there is not. What you're looking for is the advanced behaviour of a script, which you won't find in UNIX commands as they are designed to do one simple thing and do it well.
You could write a script to automatically tell a file from a directory and hence use the appropriate rm or rmdir (first requirement), but you'd need to run the script with root privileges for it to be able to remove root-owned files (second requirement). In fact, you can't increase privileges in a root script.
One could usesudo(or equivalent) in the script (or better, function) to escalate privileges. The issue is dealing with command line flags and command line flag-like file names. You would have to do full processing of the command line to be able to correctly pass on any user-supplied flags to the realrm.
â Kusalananda
Oct 30 '17 at 10:13
I'm not talking about Unix commands. I'm talking about programs in general. I could easily write one myself even insh. I just don't want to do that, if someone else already done that.
â user1685095
Oct 30 '17 at 12:02
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
No, there is not. What you're looking for is the advanced behaviour of a script, which you won't find in UNIX commands as they are designed to do one simple thing and do it well.
You could write a script to automatically tell a file from a directory and hence use the appropriate rm or rmdir (first requirement), but you'd need to run the script with root privileges for it to be able to remove root-owned files (second requirement). In fact, you can't increase privileges in a root script.
One could usesudo(or equivalent) in the script (or better, function) to escalate privileges. The issue is dealing with command line flags and command line flag-like file names. You would have to do full processing of the command line to be able to correctly pass on any user-supplied flags to the realrm.
â Kusalananda
Oct 30 '17 at 10:13
I'm not talking about Unix commands. I'm talking about programs in general. I could easily write one myself even insh. I just don't want to do that, if someone else already done that.
â user1685095
Oct 30 '17 at 12:02
add a comment |Â
up vote
4
down vote
No, there is not. What you're looking for is the advanced behaviour of a script, which you won't find in UNIX commands as they are designed to do one simple thing and do it well.
You could write a script to automatically tell a file from a directory and hence use the appropriate rm or rmdir (first requirement), but you'd need to run the script with root privileges for it to be able to remove root-owned files (second requirement). In fact, you can't increase privileges in a root script.
One could usesudo(or equivalent) in the script (or better, function) to escalate privileges. The issue is dealing with command line flags and command line flag-like file names. You would have to do full processing of the command line to be able to correctly pass on any user-supplied flags to the realrm.
â Kusalananda
Oct 30 '17 at 10:13
I'm not talking about Unix commands. I'm talking about programs in general. I could easily write one myself even insh. I just don't want to do that, if someone else already done that.
â user1685095
Oct 30 '17 at 12:02
add a comment |Â
up vote
4
down vote
up vote
4
down vote
No, there is not. What you're looking for is the advanced behaviour of a script, which you won't find in UNIX commands as they are designed to do one simple thing and do it well.
You could write a script to automatically tell a file from a directory and hence use the appropriate rm or rmdir (first requirement), but you'd need to run the script with root privileges for it to be able to remove root-owned files (second requirement). In fact, you can't increase privileges in a root script.
No, there is not. What you're looking for is the advanced behaviour of a script, which you won't find in UNIX commands as they are designed to do one simple thing and do it well.
You could write a script to automatically tell a file from a directory and hence use the appropriate rm or rmdir (first requirement), but you'd need to run the script with root privileges for it to be able to remove root-owned files (second requirement). In fact, you can't increase privileges in a root script.
answered Oct 30 '17 at 9:59
dr01
15.3k114769
15.3k114769
One could usesudo(or equivalent) in the script (or better, function) to escalate privileges. The issue is dealing with command line flags and command line flag-like file names. You would have to do full processing of the command line to be able to correctly pass on any user-supplied flags to the realrm.
â Kusalananda
Oct 30 '17 at 10:13
I'm not talking about Unix commands. I'm talking about programs in general. I could easily write one myself even insh. I just don't want to do that, if someone else already done that.
â user1685095
Oct 30 '17 at 12:02
add a comment |Â
One could usesudo(or equivalent) in the script (or better, function) to escalate privileges. The issue is dealing with command line flags and command line flag-like file names. You would have to do full processing of the command line to be able to correctly pass on any user-supplied flags to the realrm.
â Kusalananda
Oct 30 '17 at 10:13
I'm not talking about Unix commands. I'm talking about programs in general. I could easily write one myself even insh. I just don't want to do that, if someone else already done that.
â user1685095
Oct 30 '17 at 12:02
One could use
sudo (or equivalent) in the script (or better, function) to escalate privileges. The issue is dealing with command line flags and command line flag-like file names. You would have to do full processing of the command line to be able to correctly pass on any user-supplied flags to the real rm.â Kusalananda
Oct 30 '17 at 10:13
One could use
sudo (or equivalent) in the script (or better, function) to escalate privileges. The issue is dealing with command line flags and command line flag-like file names. You would have to do full processing of the command line to be able to correctly pass on any user-supplied flags to the real rm.â Kusalananda
Oct 30 '17 at 10:13
I'm not talking about Unix commands. I'm talking about programs in general. I could easily write one myself even in
sh. I just don't want to do that, if someone else already done that.â user1685095
Oct 30 '17 at 12:02
I'm not talking about Unix commands. I'm talking about programs in general. I could easily write one myself even in
sh. I just don't want to do that, if someone else already done that.â user1685095
Oct 30 '17 at 12:02
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f401371%2finteractive-rm-command%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
It doesn't matter who owns
foo/bar(as long asfoodoesn't have thetbit). To be able to delete it, you only need write access tofoo.â Stéphane Chazelas
Oct 30 '17 at 10:29