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;
}







1















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)










share|improve this question









New contributor




chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    1















    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)










    share|improve this question









    New contributor




    chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1


      1






      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)










      share|improve this question









      New contributor




      chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      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






      share|improve this question









      New contributor




      chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 1 hour ago









      Jeff Schaller

      45k1164147




      45k1164147






      New contributor




      chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 hours ago









      chintogtokhchintogtokh

      1061




      1061




      New contributor




      chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      chintogtokh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          2














          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.






          share|improve this answer

































            0














            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 *





            share|improve this answer
























              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.










              draft saved

              draft discarded


















              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









              2














              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.






              share|improve this answer






























                2














                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.






                share|improve this answer




























                  2












                  2








                  2







                  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.






                  share|improve this answer















                  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.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 1 hour ago









                  muru

                  37.9k590166




                  37.9k590166










                  answered 1 hour ago









                  AsenMAsenM

                  423210




                  423210

























                      0














                      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 *





                      share|improve this answer




























                        0














                        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 *





                        share|improve this answer


























                          0












                          0








                          0







                          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 *





                          share|improve this answer













                          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 *






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 1 hour ago









                          Jeff SchallerJeff Schaller

                          45k1164147




                          45k1164147






















                              chintogtokh is a new contributor. Be nice, and check out our Code of Conduct.










                              draft saved

                              draft discarded


















                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                              Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                              Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m