How can I make rm -rf ask for confirmation just once at the directory level? Announcing the...
How discoverable are IPv6 addresses and AAAA names by potential attackers?
Why is "Captain Marvel" translated as male in Portugal?
Is there a service that would inform me whenever a new direct route is scheduled from a given airport?
Diagram with tikz
What is the musical term for a note that continously plays through a melody?
Why does Python start at index -1 when indexing a list from the end?
What do you call a plan that's an alternative plan in case your initial plan fails?
If Jon Snow became King of the Seven Kingdoms what would his regnal number be?
Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?
What LEGO pieces have "real-world" functionality?
Do I really need recursive chmod to restrict access to a folder?
How widely used is the term Treppenwitz? Is it something that most Germans know?
How to find all the available tools in macOS terminal?
iPhone Wallpaper?
What do you call a phrase that's not an idiom yet?
Disable hyphenation for an entire paragraph
Why was the term "discrete" used in discrete logarithm?
Using et al. for a last / senior author rather than for a first author
The logistics of corpse disposal
How can I make names more distinctive without making them longer?
Do you forfeit tax refunds/credits if you aren't required to and don't file by April 15?
Why did the IBM 650 use bi-quinary?
How can players work together to take actions that are otherwise impossible?
When is phishing education going too far?
How can I make rm -rf ask for confirmation just once at the directory level?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionHow to remove all the files in a directory?Double rm verification in zshHow to count occurrences of all the words in all the files of a directory using grep? But with count incremented only once per word per fileHow does Linux format itself while running?How can I handicap the `rm` command?How can I remove just the writable files in a directory, without any prompt?Delete directories that contain a certain fileCan i enable asking for confirmation when executing a pasted command in bash?rm -iR does not work inside a loopHow can I grep each file in a directory for a keyword and output the keyword and the filename it was found in?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
If I use rm -rfi
, this asks me every time each file is deleted. If I have a list of rm -rf
commands, how can I make it so that the machine asks me for confirmation just once (when trying to delete the directory itself)
bash directory rm interactive
New contributor
add a comment |
If I use rm -rfi
, this asks me every time each file is deleted. If I have a list of rm -rf
commands, how can I make it so that the machine asks me for confirmation just once (when trying to delete the directory itself)
bash directory rm interactive
New contributor
add a comment |
If I use rm -rfi
, this asks me every time each file is deleted. If I have a list of rm -rf
commands, how can I make it so that the machine asks me for confirmation just once (when trying to delete the directory itself)
bash directory rm interactive
New contributor
If I use rm -rfi
, this asks me every time each file is deleted. If I have a list of rm -rf
commands, how can I make it so that the machine asks me for confirmation just once (when trying to delete the directory itself)
bash directory rm interactive
bash directory rm interactive
New contributor
New contributor
edited 1 hour ago
Jeff Schaller♦
45k1164147
45k1164147
New contributor
asked 2 hours ago
chintogtokhchintogtokh
1061
1061
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The -I
(capital i) is what you are looking for.
-i
asks for confirmation for every file, while the -I
(capital i) ask for confirmation when files are more than 3 or you are deleting recursively.
add a comment |
zsh -c 'rm -f **/*(^/)'
rm -ri *
This will recursively (**
) remove everything (*
) that isn't a directory (^/
) with zsh
; then use your existing shell to interactively remove what's left (directories). To include dotfiles in the initial removal, use:
zsh -c 'rm -f **/*(D^/)'
followed by:
rm -ri *
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
chintogtokh is a new contributor. Be nice, and check out our Code of Conduct.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512685%2fhow-can-i-make-rm-rf-ask-for-confirmation-just-once-at-the-directory-level%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The -I
(capital i) is what you are looking for.
-i
asks for confirmation for every file, while the -I
(capital i) ask for confirmation when files are more than 3 or you are deleting recursively.
add a comment |
The -I
(capital i) is what you are looking for.
-i
asks for confirmation for every file, while the -I
(capital i) ask for confirmation when files are more than 3 or you are deleting recursively.
add a comment |
The -I
(capital i) is what you are looking for.
-i
asks for confirmation for every file, while the -I
(capital i) ask for confirmation when files are more than 3 or you are deleting recursively.
The -I
(capital i) is what you are looking for.
-i
asks for confirmation for every file, while the -I
(capital i) ask for confirmation when files are more than 3 or you are deleting recursively.
edited 1 hour ago
muru
37.9k590166
37.9k590166
answered 1 hour ago
AsenMAsenM
423210
423210
add a comment |
add a comment |
zsh -c 'rm -f **/*(^/)'
rm -ri *
This will recursively (**
) remove everything (*
) that isn't a directory (^/
) with zsh
; then use your existing shell to interactively remove what's left (directories). To include dotfiles in the initial removal, use:
zsh -c 'rm -f **/*(D^/)'
followed by:
rm -ri *
add a comment |
zsh -c 'rm -f **/*(^/)'
rm -ri *
This will recursively (**
) remove everything (*
) that isn't a directory (^/
) with zsh
; then use your existing shell to interactively remove what's left (directories). To include dotfiles in the initial removal, use:
zsh -c 'rm -f **/*(D^/)'
followed by:
rm -ri *
add a comment |
zsh -c 'rm -f **/*(^/)'
rm -ri *
This will recursively (**
) remove everything (*
) that isn't a directory (^/
) with zsh
; then use your existing shell to interactively remove what's left (directories). To include dotfiles in the initial removal, use:
zsh -c 'rm -f **/*(D^/)'
followed by:
rm -ri *
zsh -c 'rm -f **/*(^/)'
rm -ri *
This will recursively (**
) remove everything (*
) that isn't a directory (^/
) with zsh
; then use your existing shell to interactively remove what's left (directories). To include dotfiles in the initial removal, use:
zsh -c 'rm -f **/*(D^/)'
followed by:
rm -ri *
answered 1 hour ago
Jeff Schaller♦Jeff Schaller
45k1164147
45k1164147
add a comment |
add a comment |
chintogtokh is a new contributor. Be nice, and check out our Code of Conduct.
chintogtokh is a new contributor. Be nice, and check out our Code of Conduct.
chintogtokh is a new contributor. Be nice, and check out our Code of Conduct.
chintogtokh is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512685%2fhow-can-i-make-rm-rf-ask-for-confirmation-just-once-at-the-directory-level%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown